Module: Evilution::TempDirTracker Private

Defined in:
lib/evilution/temp_dir_tracker.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.cleanup_allObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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

.unregister(dir) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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