Module: Evilution::TempDirTracker

Defined in:
lib/evilution/temp_dir_tracker.rb

Class Method Summary collapse

Class Method Details

.cleanup_allObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/evilution/temp_dir_tracker.rb', line 23

def self.cleanup_all
  # Trap-safe: Signal.trap handlers forbid Monitor#synchronize, so both the
  # snapshot and the per-dir tracking removal fall back to a lock-free path
  # when ThreadError is raised. Successful removals drop the entry from
  # @dirs; failures stay tracked so a later cleanup can retry.
  snapshot_tracked_dirs.each do |d|
    FileUtils.rm_rf(d)
    remove_from_tracking(d)
  rescue StandardError
    nil
  end
end

.register(dir) ⇒ Object



12
13
14
15
16
17
# File 'lib/evilution/temp_dir_tracker.rb', line 12

def self.register(dir)
  @monitor.synchronize do
    @dirs << dir
    register_at_exit unless @at_exit_registered
  end
end

.tracked_dirsObject



36
37
38
# File 'lib/evilution/temp_dir_tracker.rb', line 36

def self.tracked_dirs
  @monitor.synchronize { @dirs.dup }
end

.unregister(dir) ⇒ Object



19
20
21
# File 'lib/evilution/temp_dir_tracker.rb', line 19

def self.unregister(dir)
  @monitor.synchronize { @dirs.delete(dir) }
end