I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit a8976d25 authored by zzz's avatar zzz
Browse files

Profiles: Delete old ones after saving (ticket #1328)

parent 6a72c295
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,7 @@ class PeerManager {
*/
private static final long REORGANIZE_TIME_LONG = 351*1000;
private static final long STORE_TIME = 19*60*60*1000;
private static final long EXPIRE_AGE = 3*24*60*60*1000;
public static final String TRACKED_CAPS = "" +
FloodfillNetworkDatabaseFacade.CAPABILITY_FLOODFILL +
......@@ -102,7 +103,8 @@ class PeerManager {
}
/**
* Reorganize the profiles. Also periodically store them.
* Reorganize the profiles. Also periodically store them,
* and delete very old ones.
*
* This takes too long to run on the SimpleTimer2 queue
* @since 0.9.10
......@@ -131,6 +133,7 @@ class PeerManager {
try {
_log.debug("Periodic profile store start");
storeProfiles();
_persistenceHelper.deleteOldProfiles(EXPIRE_AGE);
_log.debug("Periodic profile store end");
} catch (Throwable t) {
_log.log(Log.CRIT, "Error storing profiles", t);
......
......@@ -229,6 +229,26 @@ class ProfilePersistenceHelper {
}
}
/**
* Delete profile files with timestamps older than 'age' ago
* @since 0.9.28
*/
public void deleteOldProfiles(long age) {
long cutoff = System.currentTimeMillis() - age;
List<File> files = selectFiles();
int i = 0;
for (File f : files) {
if (!f.isFile())
continue;
if (f.lastModified() < cutoff) {
i++;
f.delete();
}
}
if (_log.shouldWarn())
_log.warn("Deleted " + i + " old profiles");
}
private boolean isExpired(long lastSentToSuccessfully) {
long timeSince = _context.clock().now() - lastSentToSuccessfully;
return (timeSince > EXPIRE_AGE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment