Esempio n. 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();
  }
Esempio n. 2
0
  private void crawlForOrphans(VFSContainer container, List<OrphanVersion> orphans) {
    if (!container.exists()) {
      return;
    }

    List<VFSItem> children = container.getItems();
    for (VFSItem child : children) {
      if (child instanceof VFSContainer) {
        crawlForOrphans((VFSContainer) child, orphans);
      }
      if (child instanceof VFSLeaf) {
        VFSLeaf versionsLeaf = (VFSLeaf) child;
        if (child.getName().endsWith(".xml")) {
          Versions versions = isOrphan(versionsLeaf);
          if (versions == null) {
            continue;
          } else {
            List<VFSRevision> revisions = versions.getRevisions();
            if (revisions != null) {
              for (VFSRevision revision : revisions) {
                if (revision instanceof RevisionFileImpl) {
                  ((RevisionFileImpl) revision).setContainer(container);
                }
              }
            }
          }
          File originalFile = reversedOriginFile(child);
          if (!originalFile.exists()) {
            VFSLeaf orphan = new LocalFileImpl(originalFile);
            orphans.add(new OrphanVersion(orphan, versionsLeaf, versions));
          }
        }
      }
    }
  }
 @Test
 public void testGenerateDir() {
   String uuid = UUID.randomUUID().toString();
   String dir = qpoolFileStorage.generateDir(uuid);
   Assert.assertNotNull(dir);
   VFSContainer container = qpoolFileStorage.getContainer(dir);
   Assert.assertTrue(container.exists());
 }
Esempio n. 4
0
 @Override
 public int countDirectories() {
   VFSContainer versionsContainer = getRootVersionsContainer();
   if (versionsContainer.exists()) {
     return countDirectories(versionsContainer);
   }
   return 0;
 }