コード例 #1
0
  @Override
  public void pruneHistory(long maxHistoryLength, ProgressDelegate progress) {
    VFSContainer versionsContainer = getRootVersionsContainer();
    if (!versionsContainer.exists()) {
      return;
    }
    // delete folder without versioning first

    int count = 0;
    String[] excludedRootFolders = new String[] {"tmp", "scorm", "forum", "portfolio"};
    for (String excludedRootFolder : excludedRootFolders) {
      VFSItem excludedContainer = versionsContainer.resolve(excludedRootFolder);
      if (excludedContainer instanceof LocalFolderImpl) {
        File excludedFile = ((LocalFolderImpl) excludedContainer).getBasefile();
        FileUtils.deleteQuietly(excludedFile);
        if (progress != null) progress.setInfo(excludedContainer.getName());
      }
      if (progress != null) progress.setActual(++count);
    }

    if (maxHistoryLength < 0) {
      // nothing to do
    } else if (maxHistoryLength == 0 && versionsContainer instanceof LocalFolderImpl) {
      // delete all the stuff
      FileUtils.deleteQuietly(((LocalFolderImpl) versionsContainer).getBasefile());
    } else {
      pruneVersionHistory(versionsContainer, maxHistoryLength, progress, count);
    }

    if (progress != null) progress.finished();
  }
コード例 #2
0
 @Override
 public boolean deleteOrphans(ProgressDelegate progress) {
   List<OrphanVersion> orphans = orphans();
   if (progress != null) progress.setMax(orphans.size());
   int count = 0;
   for (OrphanVersion orphan : orphans) {
     delete(orphan);
     if (progress != null) {
       progress.setActual(++count);
       progress.setInfo(orphan.getOriginalFilePath());
     }
   }
   if (progress != null) progress.finished();
   return true;
 }
コード例 #3
0
 private void pruneVersionHistory(
     VFSContainer container, long maxHistoryLength, ProgressDelegate progress, int count) {
   List<VFSItem> children = container.getItems(new SystemItemFilter());
   for (VFSItem child : children) {
     if (child instanceof VFSContainer) {
       if (progress != null) progress.setActual(++count);
       pruneVersionHistory((VFSContainer) child, maxHistoryLength, progress, count);
     }
     if (child instanceof VFSLeaf) {
       VFSLeaf versionsLeaf = (VFSLeaf) child;
       pruneVersionHistory(versionsLeaf, maxHistoryLength, progress);
     }
   }
 }
コード例 #4
0
 private void pruneVersionHistory(
     VFSLeaf versionsLeaf, long maxHistoryLength, ProgressDelegate progress) {
   if (versionsLeaf.getName().endsWith(".xml") && isVersionsXmlFile(versionsLeaf)) {
     File originalFile = reversedOriginFile(versionsLeaf);
     if (originalFile.exists()) {
       VFSLeaf original = new LocalFileImpl(originalFile);
       if (progress != null) progress.setInfo(original.getName());
       Versions versions = readVersions(original, versionsLeaf);
       List<VFSRevision> revisions = versions.getRevisions();
       if (revisions.size() > maxHistoryLength) {
         List<VFSRevision> revisionsToDelete =
             revisions.subList(0, revisions.size() - (int) maxHistoryLength);
         deleteRevisions((Versionable) original, revisionsToDelete);
       }
     }
   }
 }