summaryrefslogtreecommitdiff
path: root/lib/backup
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-12-07 12:39:19 +0000
committerSean McGivern <sean@gitlab.com>2016-12-07 13:27:44 +0000
commit2fc1e643a7d8fb2fb4f9df49a2347d4f82776e99 (patch)
tree67721286df2c092684fd0e38147985c81861f62c /lib/backup
parent911c1601f81d8e0050766b533beaaf4e612c5592 (diff)
downloadgitlab-ce-2fc1e643a7d8fb2fb4f9df49a2347d4f82776e99.tar.gz
Fix Backup::Manager#remove_old25399-backup-task-is-not-working-on-8-15-pre
Diffstat (limited to 'lib/backup')
-rw-r--r--lib/backup/manager.rb19
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