All Implemented Interfaces:
Runnable

public class TempDirScannerextends SimpleTimer2.TimedEvent
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 Details

    • ctx

      private final I2PAppContext ctx
      Context whose temp directory is scanned.
    • DELAY

      private static final long DELAY
      Milliseconds 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

      public TempDirScanner(I2PAppContext context)
      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.TimedEvent
      Called when this event's scheduled time arrives. Must NOT block. For periodic events, call schedule(period) at the end to self-reschedule.
      Specified by:
      timeReached in class SimpleTimer2.TimedEvent
    • scan

      private static void scan(File f)
      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