java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.util.TempDirScanner
- All Implemented Interfaces:
Runnable
Prevent systemd from deleting our temp dir or any dirs or files in it. Scheduled by
I2PAppContext when the temp dir is created.To configure/test systemd: Edit file /usr/lib/tmpfiles.d/tmp.conf, change line D /tmp 1777 root root - to D /tmp 1777 root root 24h
Ref: https://lwn.net/Articles/975565/ Ref: https://systemd.io/TEMPORARY_DIRECTORIES/ Ref: man systemd-tmpfiles; man tmpfiles.d.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final I2PAppContextContext whose temp directory is scanned.private static final longMilliseconds between scans, a little under a day.Fields inherited from class SimpleTimer2.TimedEvent
_state, DEFAULT_FUZZModifier and TypeFieldDescriptionprotected SimpleTimer2.TimedEventStateState of the current event.protected static final intDefault fuzz threshold in milliseconds.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate static voidRecursively timestamp all files and empty dirs We can't count on the filesystem updating access time.voidCalled when this event's scheduled time arrives.Methods inherited from class SimpleTimer2.TimedEvent
cancel, forceReschedule, reschedule, reschedule, run, schedule, setFuzz, setPool, toStringModifier and TypeMethodDescriptionbooleancancel()Cancel the timed event.voidforceReschedule(long timeoutMs) Always use the new time - ignores fuzz.voidreschedule(long timeoutMs) Use the earliest of the new time and the old time May be called from within timeReached(), but schedule() is better there.voidreschedule(long timeoutMs, boolean useEarliestTime) May be called from within timeReached(), but schedule() is better there.voidrun()voidschedule(long timeoutMs) Schedule this event.voidsetFuzz(int fuzz) Reschedule threshold in ms.voidsetPool(SimpleTimer2 pool) Timer pool for this event.toString()Timer summary for log messages.
Field Details
ctx
Context whose temp directory is scanned.DELAY
private static final long DELAYMilliseconds between scans, a little under a day. systemd's default for /tmp is 10 days, distro dependent, so scan sooner to be safe.- See Also:
Constructor Details
TempDirScanner
Schedules itself.- Parameters:
context- the app context whose temp dir is kept alive and whose timer scans it
Method Details
timeReached
public void timeReached()Description copied from class:SimpleTimer2.TimedEventCalled when this event's scheduled time arrives. Must NOT block. For periodic events, call schedule(period) at the end to self-reschedule.- Specified by:
timeReachedin classSimpleTimer2.TimedEvent
scan
Recursively timestamp all files and empty dirs We can't count on the filesystem updating access time. This should not affect any known usage of our temp dir.- Parameters:
f- the file or directory to scan