Skip to content

Commit

Permalink
delete old releases compatible with java 1.5 ;)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4728 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
danielr committed Apr 23, 2008
1 parent e90282d commit 7bd8601
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions source/de/anomic/yacy/yacyVersion.java
Expand Up @@ -38,6 +38,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -511,7 +512,7 @@ public static void deleteOldDownloads(File filesPath, int deleteAfterDays) {
String[] downloaded = filesPath.list();

// parse all filenames and put them in a sorted set
TreeSet<yacyVersion> downloadedreleases = new TreeSet<yacyVersion>();
SortedSet<yacyVersion> downloadedreleases = new TreeSet<yacyVersion>();
for (int j = 0; j < downloaded.length; j++) {
try {
release = new yacyVersion(downloaded[j]);
Expand All @@ -534,18 +535,18 @@ public static void deleteOldDownloads(File filesPath, int deleteAfterDays) {
// remove old files
long now = System.currentTimeMillis();
final long deleteAfterMillis = deleteAfterDays * 24 * 60 * 60000l;
final Iterator<yacyVersion> iter = downloadedreleases.descendingIterator();
while (iter.hasNext()) {
release = iter.next();

if(keepMain && release.mainRelease) {
// we found the latest main release
keepMain = false;
continue;
String lastMain = null;
for (final yacyVersion aRelease: downloadedreleases) {
if(keepMain && aRelease.mainRelease) {
// keep this one, delete last remembered main release file
if(lastMain != null) {
aRelease.name = lastMain;
}
lastMain = aRelease.name;
}

// check file age
File downloadedFile = new File(filesPath + File.separator + release.name);
File downloadedFile = new File(filesPath + File.separator + aRelease.name);
if(now - downloadedFile.lastModified() > deleteAfterMillis) {
// delete file
if(!downloadedFile.delete()) {
Expand Down

0 comments on commit 7bd8601

Please sign in to comment.