diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-06-22 01:03:26 +0000 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-07-19 22:28:17 -0500 |
commit | 3a7b724f6a03a19719b05b30e1e76e536230bcca (patch) | |
tree | 077e1e76d9cd1a2ded429386bb374f2260f58782 /db | |
parent | d3d877813cab8bfdc25ef06011a95190871e3f8e (diff) | |
download | gitlab-ce-3a7b724f6a03a19719b05b30e1e76e536230bcca.tar.gz |
Merge branch 'bvl-remove-appearance-symlink' into 'security-9-3'
Remove the `appearance` symlink that was previously missed
See merge request !2124
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20170406111121_clean_upload_symlinks.rb | 2 | ||||
-rw-r--r-- | db/post_migrate/20170613111224_clean_appearance_symlinks.rb | 52 |
2 files changed, 53 insertions, 1 deletions
diff --git a/db/post_migrate/20170406111121_clean_upload_symlinks.rb b/db/post_migrate/20170406111121_clean_upload_symlinks.rb index 3ac9a6c10bc..fc3a4acc0bb 100644 --- a/db/post_migrate/20170406111121_clean_upload_symlinks.rb +++ b/db/post_migrate/20170406111121_clean_upload_symlinks.rb @@ -6,7 +6,7 @@ class CleanUploadSymlinks < ActiveRecord::Migration disable_ddl_transaction! DOWNTIME = false - DIRECTORIES_TO_MOVE = %w(user project note group appeareance) + DIRECTORIES_TO_MOVE = %w(user project note group appearance) def up return unless file_storage? diff --git a/db/post_migrate/20170613111224_clean_appearance_symlinks.rb b/db/post_migrate/20170613111224_clean_appearance_symlinks.rb new file mode 100644 index 00000000000..acb895e426f --- /dev/null +++ b/db/post_migrate/20170613111224_clean_appearance_symlinks.rb @@ -0,0 +1,52 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class CleanAppearanceSymlinks < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + disable_ddl_transaction! + + DOWNTIME = false + + def up + return unless file_storage? + + symlink_location = File.join(old_upload_dir, dir) + + return unless File.symlink?(symlink_location) + say "removing symlink: #{symlink_location}" + FileUtils.rm(symlink_location) + end + + def down + return unless file_storage? + + symlink = File.join(old_upload_dir, dir) + destination = File.join(new_upload_dir, dir) + + return if File.directory?(symlink) + return unless File.directory?(destination) + + say "Creating symlink #{symlink} -> #{destination}" + FileUtils.ln_s(destination, symlink) + end + + def file_storage? + CarrierWave::Uploader::Base.storage == CarrierWave::Storage::File + end + + def dir + 'appearance' + end + + def base_directory + Rails.root + end + + def old_upload_dir + File.join(base_directory, "public", "uploads") + end + + def new_upload_dir + File.join(base_directory, "public", "uploads", "system") + end +end |