summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2017-11-21 00:23:43 +0100
committerGabriel Mazetto <brodock@gmail.com>2017-11-23 14:19:36 +0100
commit9fd31eb469de5099f7a7b44840d7930bc3c42bbe (patch)
treea634ff9876e04d1ec088147f92171a753e1350cb
parentf0f6a237d7e95fcc5d52e85aef151f0327bf2fdc (diff)
downloadgitlab-ce-9fd31eb469de5099f7a7b44840d7930bc3c42bbe.tar.gz
Raises error when migration cannot happen so job is cancelled
-rw-r--r--app/services/projects/hashed_storage/migrate_attachments_service.rb4
-rw-r--r--spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb7
2 files changed, 5 insertions, 6 deletions
diff --git a/app/services/projects/hashed_storage/migrate_attachments_service.rb b/app/services/projects/hashed_storage/migrate_attachments_service.rb
index 68b9a72661c..26026899ebe 100644
--- a/app/services/projects/hashed_storage/migrate_attachments_service.rb
+++ b/app/services/projects/hashed_storage/migrate_attachments_service.rb
@@ -1,5 +1,7 @@
module Projects
module HashedStorage
+ AttachmentMigrationError = Class.new(StandardError)
+
class MigrateAttachmentsService < BaseService
attr_reader :logger
@@ -27,7 +29,7 @@ module Projects
if File.exist?(new_path)
logger.error("Cannot migrate attachments from '#{old_path}' to '#{new_path}', target path already exist (PROJECT_ID=#{project.id})")
- return
+ raise AttachmentMigrationError, "Target path '#{new_path}' already exist"
end
# Create hashed storage base path folder
diff --git a/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb b/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
index ce43a7e4d54..de2abfc1985 100644
--- a/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
+++ b/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
@@ -49,13 +49,10 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
FileUtils.mkdir_p(base_path(hashed_storage))
end
- it 'skips moving the file and goes to next' do
+ it 'raises AttachmentMigrationError' do
expect(FileUtils).not_to receive(:mv).with(base_path(legacy_storage), base_path(hashed_storage))
- service.execute
-
- expect(File.exist?(base_path(legacy_storage))).to be_truthy
- expect(File.file?(old_path)).to be_truthy
+ expect { service.execute }.to raise_error(Projects::HashedStorage::AttachmentMigrationError)
end
end
end