diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-19 08:57:35 -0800 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-02-19 08:57:35 -0800 |
commit | 8184a6564454faf0f9ae9dfee1377c3407d08447 (patch) | |
tree | 0858476b0f6292ee1069c223283d8bc2cb932fc9 /lib/backup | |
parent | 7c3147e6e969a7ae97e2f8d05e536abeeb7d3936 (diff) | |
download | gitlab-ce-8184a6564454faf0f9ae9dfee1377c3407d08447.tar.gz |
Revert "Fix broken access control and refactor avatar upload"
This reverts commit 7d5f86f6cbd187e75a6ba164ad6bfd036977dd07.
Diffstat (limited to 'lib/backup')
-rw-r--r-- | lib/backup/manager.rb | 2 | ||||
-rw-r--r-- | lib/backup/uploads.rb | 40 |
2 files changed, 13 insertions, 29 deletions
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index 06cd40a5b1c..ab8db4e9837 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -1,6 +1,6 @@ module Backup class Manager - BACKUP_CONTENTS = %w{repositories/ db/ public/ uploads/ backup_information.yml} + BACKUP_CONTENTS = %w{repositories/ db/ uploads/ backup_information.yml} def pack # saving additional informations diff --git a/lib/backup/uploads.rb b/lib/backup/uploads.rb index 75d8e18a862..e50e1ff4f13 100644 --- a/lib/backup/uploads.rb +++ b/lib/backup/uploads.rb @@ -1,45 +1,29 @@ module Backup class Uploads - attr_reader :app_public_uploads_dir, :app_private_uploads_dir, :backup_public_uploads_dir, - :backup_private_uploads_dir, :backup_dir, :backup_public_dir + attr_reader :app_uploads_dir, :backup_uploads_dir, :backup_dir def initialize - @app_public_uploads_dir = File.realpath(Rails.root.join('public', 'uploads')) - @app_private_uploads_dir = File.realpath(Rails.root.join('uploads')) + @app_uploads_dir = File.realpath(Rails.root.join('public', 'uploads')) @backup_dir = Gitlab.config.backup.path - @backup_public_dir = File.join(backup_dir, 'public') - @backup_public_uploads_dir = File.join(backup_dir, 'public', 'uploads') - @backup_private_uploads_dir = File.join(backup_dir, 'uploads') + @backup_uploads_dir = File.join(Gitlab.config.backup.path, 'uploads') end - # Copy uploads from public/uploads to backup/public/uploads and from /uploads to backup/uploads + # Copy uploads from public/uploads to backup/uploads def dump - FileUtils.mkdir_p(backup_public_uploads_dir) - FileUtils.cp_r(app_public_uploads_dir, backup_public_dir) - - FileUtils.mkdir_p(backup_private_uploads_dir) - FileUtils.cp_r(app_private_uploads_dir, backup_dir) + FileUtils.mkdir_p(backup_uploads_dir) + FileUtils.cp_r(app_uploads_dir, backup_dir) end def restore - backup_existing_public_uploads_dir - backup_existing_private_uploads_dir + backup_existing_uploads_dir - FileUtils.cp_r(backup_public_uploads_dir, app_public_uploads_dir) - FileUtils.cp_r(backup_private_uploads_dir, app_private_uploads_dir) + FileUtils.cp_r(backup_uploads_dir, app_uploads_dir) end - def backup_existing_public_uploads_dir - timestamped_public_uploads_path = File.join(app_public_uploads_dir, '..', "uploads.#{Time.now.to_i}") - if File.exists?(app_public_uploads_dir) - FileUtils.mv(app_public_uploads_dir, timestamped_public_uploads_path) - end - end - - def backup_existing_private_uploads_dir - timestamped_private_uploads_path = File.join(app_private_uploads_dir, '..', "uploads.#{Time.now.to_i}") - if File.exists?(app_private_uploads_dir) - FileUtils.mv(app_private_uploads_dir, timestamped_private_uploads_path) + 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, timestamped_uploads_path) end end end |