Skip to content

Commit

Permalink
Update disk_utilities_helper.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzfreiheit authored Jul 28, 2021
1 parent eae5ee7 commit 8d6e0df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/helpers/deepblue/disk_utilities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def self.delete_dirs_glob_regexp( base_dir:, glob: '*', filename_regexp: nil, da
dirs = dirs_in_dir( base_dir, glob: glob )
if filename_regexp.present?
dirs = dirs.select do |dir|
dir = File.basename file
dir = File.basename dir
dir =~ filename_regexp
end
end
Expand All @@ -54,7 +54,13 @@ def self.delete_dirs_glob_regexp( base_dir:, glob: '*', filename_regexp: nil, da
def self.delete_dirs_older_than( *dirs, days_old:, recursive: false )
return delete_dirs( *files, recursive: recursive ) if days_old <= 0
older_than = DateTime.now - days_old.days
dirs = dirs.select { |dir| File.mtime( dir ) < older_than }
dirs = dirs.select do |dir|
if dir.is_a? Array
false # TODO: find out why we have to do this
else
File.mtime( dir ) < older_than
end
end
delete_files( *dirs, recursive: recursive )
end

Expand Down

0 comments on commit 8d6e0df

Please sign in to comment.