diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2017-11-24 11:59:21 +0300 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2017-11-28 13:22:23 +0300 |
commit | 58f32622ce9c2d08001da7b91065942cdc5a0f4a (patch) | |
tree | 8a476daa179fa9eb9e0839f886714d74c91c5cec /app/services | |
parent | dc62441ffd47d63f342c6accbd5049f6e8f99303 (diff) |
Changes to Attachments Migration for EE and Geo compatibility
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/hashed_storage/migrate_attachments_service.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/app/services/projects/hashed_storage/migrate_attachments_service.rb b/app/services/projects/hashed_storage/migrate_attachments_service.rb index 8cac6221a96..f8aaec8a9c0 100644 --- a/app/services/projects/hashed_storage/migrate_attachments_service.rb +++ b/app/services/projects/hashed_storage/migrate_attachments_service.rb @@ -3,7 +3,7 @@ module Projects AttachmentMigrationError = Class.new(StandardError) class MigrateAttachmentsService < BaseService - attr_reader :logger + attr_reader :logger, :old_path, :new_path def initialize(project, logger = nil) @project = project @@ -11,16 +11,21 @@ module Projects end def execute - old_path = FileUploader.dynamic_path_segment(project) + @old_path = project.full_path + @new_path = project.disk_path + + origin = FileUploader.dynamic_path_segment(project) project.storage_version = ::Project::HASHED_STORAGE_FEATURES[:attachments] - new_path = FileUploader.dynamic_path_segment(project) + target = FileUploader.dynamic_path_segment(project) - move_folder!(old_path, new_path) + result = move_folder!(origin, target) project.save! - if block_given? + if result && block_given? yield end + + result end private @@ -41,6 +46,8 @@ module Projects FileUtils.mv(old_path, new_path) logger.info("Migrated project attachments from '#{old_path}' to '#{new_path}' (PROJECT_ID=#{project.id})") + + true end end end |