Commit fb9b114d38f4f0eb91673f3555b11b1c952954cf

Authored by Jacob Vosmaer
1 parent 4686104c

Patch gitlab-rails for uploads backup restore

config/patches/gitlab-rails/backup_uploads_realpath.patch 0 → 100644
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
  1 +diff --git a/lib/backup/uploads.rb b/lib/backup/uploads.rb
  2 +index e79da7e..e50e1ff 100644
  3 +--- a/lib/backup/uploads.rb
  4 ++++ b/lib/backup/uploads.rb
  5 +@@ -3,7 +3,7 @@ module Backup
  6 + attr_reader :app_uploads_dir, :backup_uploads_dir, :backup_dir
  7 +
  8 + def initialize
  9 +- @app_uploads_dir = Rails.root.join('public', 'uploads')
  10 ++ @app_uploads_dir = File.realpath(Rails.root.join('public', 'uploads'))
  11 + @backup_dir = Gitlab.config.backup.path
  12 + @backup_uploads_dir = File.join(Gitlab.config.backup.path, 'uploads')
  13 + end
  14 +@@ -21,8 +21,9 @@ module Backup
  15 + end
  16 +
  17 + def backup_existing_uploads_dir
  18 ++ timestamped_uploads_path = File.join(app_uploads_dir, '..', "uploads.#{Time.now.to_i}")
  19 + if File.exists?(app_uploads_dir)
  20 +- FileUtils.mv(app_uploads_dir, Rails.root.join('public', "uploads.#{Time.now.to_i}"))
  21 ++ FileUtils.mv(app_uploads_dir, timestamped_uploads_path)
  22 + end
  23 + end
  24 + end
config/software/gitlab-rails.rb
@@ -46,6 +46,11 @@ build do @@ -46,6 +46,11 @@ build do
46 patch :source => "backup_read_REVISION.patch" 46 patch :source => "backup_read_REVISION.patch"
47 command "git rev-parse HEAD > REVISION" 47 command "git rev-parse HEAD > REVISION"
48 48
  49 + # The user uploads path is not (yet) configurable in gitlab-rails. As a
  50 + # workaround, omnibus-gitlab creates a symlink for public/uploads. This breaks
  51 + # the GitLab backup script.
  52 + patch :source => "backup_uploads_realpath.patch"
  53 +
49 bundle "install --without mysql development test --path=#{install_dir}/embedded/service/gem", :env => env 54 bundle "install --without mysql development test --path=#{install_dir}/embedded/service/gem", :env => env
50 55
51 # In order to precompile the assets, we need to get to a state where rake can 56 # In order to precompile the assets, we need to get to a state where rake can