diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-06-22 04:03:26 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-07-19 15:58:32 +0300 |
commit | 1c956009ed4090a2f30d34e832521cf5e8fb4812 (patch) | |
tree | 091fb6af8848591a6a088d694f70a776b758f12a /db | |
parent | 4f0ee37154f1a5f3bac7e1acf5d3ddde40f41679 (diff) |
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 |