mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 00:38:16 +00:00
Cache now gets removed after 3 days
This is based on the latest modification date, so it depends on the file when it gets removed.
This commit is contained in:
@@ -35,6 +35,8 @@ public class Directories {
|
|||||||
cached.put("Servers", new File(cached.get("Root"), "/Parabot/servers/"));
|
cached.put("Servers", new File(cached.get("Root"), "/Parabot/servers/"));
|
||||||
cached.put("Cache", new File(cached.get("Root"), "/Parabot/cache/"));
|
cached.put("Cache", new File(cached.get("Root"), "/Parabot/cache/"));
|
||||||
Core.verbose("Directories cached.");
|
Core.verbose("Directories cached.");
|
||||||
|
|
||||||
|
clearCache(259200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,4 +176,20 @@ public class Directories {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the cache based on the latest modification
|
||||||
|
* @param remove A long that represents the amount of seconds that a file may have since the latest modification
|
||||||
|
*/
|
||||||
|
private static void clearCache(int remove){
|
||||||
|
File[] cache = getCachePath().listFiles();
|
||||||
|
if (cache != null){
|
||||||
|
for (File f : cache){
|
||||||
|
if (f != null && System.currentTimeMillis() / 1000 - f.lastModified() / 1000 > remove){
|
||||||
|
Core.verbose("Clearing " + f.getName() + " from cache...");
|
||||||
|
f.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user