lib/zold/copies.rb in zold-0.26.10 vs lib/zold/copies.rb in zold-0.26.11
- old
+ new
@@ -51,13 +51,14 @@
def to_s
File.basename(@dir)
end
- def clean
+ # Delete all copies that are older than the "max" age provided, in seconds.
+ def clean(max: 24 * 60 * 60)
Futex.new(file, log: @log).open do
list = load
- list.reject! { |s| s[:time] < Time.now - 24 * 60 * 60 }
+ list.reject! { |s| s[:time] < Time.now - max }
save(list)
deleted = 0
files.each do |f|
next unless list.find { |s| s[:name] == File.basename(f, Copies::EXT) }.nil?
file = File.join(@dir, f)