Merge branch 'backup_uploads_symlink' into 'master'
Backup Uploads Symlink
This commit is contained in:
commit
54e40241f6
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue