Commit 69849ff2 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Track when MigrateAttachmentsService is skipped

We need this new state for the Geo event logic in EE
parent 02ad6e26
......@@ -14,6 +14,7 @@ module Projects
@logger = logger || Rails.logger
@old_disk_path = old_disk_path
@new_disk_path = project.disk_path
@skipped = false
end
def execute
......@@ -34,11 +35,16 @@ module Projects
result
end
def skipped?
@skipped
end
private
def move_folder!(old_path, new_path)
unless File.directory?(old_path)
logger.info("Skipped attachments migration from '#{old_path}' to '#{new_path}', source path doesn't exist or is not a directory (PROJECT_ID=#{project.id})")
@skipped = true
return true
end
......
......@@ -32,6 +32,12 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
it 'returns true' do
expect(service.execute).to be_truthy
end
it 'sets skipped to false' do
service.execute
expect(service.skipped?).to be_falsey
end
end
context 'when original folder does not exist anymore' do
......@@ -49,10 +55,14 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
end
it 'returns true' do
expect(FileUtils).not_to receive(:mv).with(base_path(legacy_storage), base_path(hashed_storage))
expect(service.execute).to be_truthy
end
it 'sets skipped to true' do
service.execute
expect(service.skipped?).to be_truthy
end
end
context 'when target folder already exists' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment