Commit a47a6f2afd7021600964b6580e863b888532031c
1 parent
5d6e4bd2
Exists in
spb-stable
and in
3 other branches
Support symlinked public/uploads for backp restore
The backup restore code moves any existing uploads directory out of the way before restoring the copy from the backup. If public/uploads was a symlink, this move would replace the symlink. This commit avoids this issue by first resolving any symlinks in the uploads path.
Showing
1 changed file
with
3 additions
and
2 deletions
Show diff stats
lib/backup/uploads.rb
... | ... | @@ -3,7 +3,7 @@ module Backup |
3 | 3 | attr_reader :app_uploads_dir, :backup_uploads_dir, :backup_dir |
4 | 4 | |
5 | 5 | def initialize |
6 | - @app_uploads_dir = Rails.root.join('public', 'uploads') | |
6 | + @app_uploads_dir = File.realpath(Rails.root.join('public', 'uploads')) | |
7 | 7 | @backup_dir = Gitlab.config.backup.path |
8 | 8 | @backup_uploads_dir = File.join(Gitlab.config.backup.path, 'uploads') |
9 | 9 | end |
... | ... | @@ -21,8 +21,9 @@ module Backup |
21 | 21 | end |
22 | 22 | |
23 | 23 | def backup_existing_uploads_dir |
24 | + timestamped_uploads_path = File.join(app_uploads_dir, '..', "uploads.#{Time.now.to_i}") | |
24 | 25 | if File.exists?(app_uploads_dir) |
25 | - FileUtils.mv(app_uploads_dir, Rails.root.join('public', "uploads.#{Time.now.to_i}")) | |
26 | + FileUtils.mv(app_uploads_dir, timestamped_uploads_path) | |
26 | 27 | end |
27 | 28 | end |
28 | 29 | end | ... | ... |