Merge branch 'backup_uploads_symlink' into 'master'

Backup Uploads Symlink
This commit is contained in:
Dmitriy Zaporozhets 2014-03-01 12:55:13 +00:00
commit 54e40241f6

View file

@ -3,7 +3,7 @@ module Backup
attr_reader :app_uploads_dir, :backup_uploads_dir, :backup_dir attr_reader :app_uploads_dir, :backup_uploads_dir, :backup_dir
def initialize 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_dir = Gitlab.config.backup.path
@backup_uploads_dir = File.join(Gitlab.config.backup.path, 'uploads') @backup_uploads_dir = File.join(Gitlab.config.backup.path, 'uploads')
end end
@ -21,8 +21,9 @@ module Backup
end end
def backup_existing_uploads_dir def backup_existing_uploads_dir
timestamped_uploads_path = File.join(app_uploads_dir, '..', "uploads.#{Time.now.to_i}")
if File.exists?(app_uploads_dir) 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 end
end end