Commit a47a6f2a authored by Jacob Vosmaer's avatar Jacob Vosmaer

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
......@@ -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
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment