/** * This standalone module is responsible for cleaning up the list of stored * extracts, so only the recent ones remain. This is meant to be linked as a * cron scheduled program. */ module cleaner; import std.stdio; import std.file; import std.path; import std.datetime; const EXTRACTS_DIR = "extracts"; int main() { immutable SysTime now = Clock.currTime(); foreach (DirEntry entry; dirEntries(EXTRACTS_DIR, SpanMode.shallow, false)) { Duration age = now - entry.timeLastModified(); if (age.total!"days" > 5) { writefln!"Removing directory %s because it's too old."(entry.name); rmdirRecurse(entry.name); } } return 0; }