diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-02-26 17:26:48 +0100 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-02-26 17:26:48 +0100 |
commit | a47a6f2afd7021600964b6580e863b888532031c (patch) | |
tree | eaa9fbb9d1a5d71e966ca1b8b223e5f8da19a807 /lib/backup | |
parent | 5d6e4bd2d8d2e45407bb437e5b22656cffedc15a (diff) | |
download | gitlab-ce-a47a6f2afd7021600964b6580e863b888532031c.tar.gz |
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.
Diffstat (limited to 'lib/backup')
-rw-r--r-- | lib/backup/uploads.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/backup/uploads.rb b/lib/backup/uploads.rb index e79da7e8fd2..e50e1ff4f13 100644 --- a/lib/backup/uploads.rb +++ b/lib/backup/uploads.rb @@ -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 |