Skip to content
Snippets Groups Projects
Commit a47a6f2a authored by Jacob Vosmaer's avatar Jacob Vosmaer
Browse files

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.
parent 5d6e4bd2
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,7 +3,7 @@ module Backup
attr_reader :app_uploads_dir, :backup_uploads_dir, :backup_dir
 
def initialize
@app_uploads_dir = Rails.root.join('public', 'uploads')
@app_uploads_dir = File.realpath(Rails.root.join('public', 'uploads'))
@backup_dir = Gitlab.config.backup.path
@backup_uploads_dir = File.join(Gitlab.config.backup.path, 'uploads')
end
Loading
Loading
@@ -21,8 +21,9 @@ module Backup
end
 
def backup_existing_uploads_dir
timestamped_uploads_path = File.join(app_uploads_dir, '..', "uploads.#{Time.now.to_i}")
if File.exists?(app_uploads_dir)
FileUtils.mv(app_uploads_dir, Rails.root.join('public', "uploads.#{Time.now.to_i}"))
FileUtils.mv(app_uploads_dir, timestamped_uploads_path)
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment