diff options
author | Sean McGivern <sean@gitlab.com> | 2016-12-07 15:39:19 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-12-07 16:27:44 +0300 |
commit | 2fc1e643a7d8fb2fb4f9df49a2347d4f82776e99 (patch) | |
tree | 67721286df2c092684fd0e38147985c81861f62c /lib/backup/manager.rb | |
parent | 911c1601f81d8e0050766b533beaaf4e612c5592 (diff) |
Fix Backup::Manager#remove_old
Diffstat (limited to 'lib/backup/manager.rb')
-rw-r--r-- | lib/backup/manager.rb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index 96c20100541..7e6537e3d9e 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -82,16 +82,17 @@ module Backup removed = 0 Dir.chdir(Gitlab.config.backup.path) do - file_list = Dir.glob('*_gitlab_backup.tar') - file_list.map! do |path_string| - if path_string =~ /(\d+)(?:_\d{4}_\d{2}_\d{2})?_gitlab_backup\.tar/ - { timestamp: $1.to_i, path: path_string } - end - end - file_list.sort.each do |file| - if Time.at(file[:timestamp]) < (Time.now - keep_time) - if Kernel.system(*%W(rm #{file[:path]})) + Dir.glob('*_gitlab_backup.tar').each do |file| + next unless file =~ /(\d+)(?:_\d{4}_\d{2}_\d{2})?_gitlab_backup\.tar/ + + timestamp = $1.to_i + + if Time.at(timestamp) < (Time.now - keep_time) + begin + FileUtils.rm(file) removed += 1 + rescue => e + $progress.puts "Deleting #{file} failed: #{e.message}".color(:red) end end end |