@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(); }
@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; }