Commit 02ac66de 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 7bc16889
...@@ -12,6 +12,7 @@ module Projects ...@@ -12,6 +12,7 @@ module Projects
@logger = logger || Rails.logger @logger = logger || Rails.logger
@old_disk_path = old_disk_path @old_disk_path = old_disk_path
@new_disk_path = project.disk_path @new_disk_path = project.disk_path
@skipped = false
end end
def execute def execute
...@@ -32,11 +33,16 @@ module Projects ...@@ -32,11 +33,16 @@ module Projects
result result
end end
def skipped?
@skipped
end
private private
def move_folder!(old_path, new_path) def move_folder!(old_path, new_path)
unless File.directory?(old_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})") 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 return true
end end
......
...@@ -32,6 +32,12 @@ describe Projects::HashedStorage::MigrateAttachmentsService do ...@@ -32,6 +32,12 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
it 'returns true' do it 'returns true' do
expect(service.execute).to be_truthy expect(service.execute).to be_truthy
end end
it 'sets skipped to false' do
service.execute
expect(service.skipped?).to be_falsey
end
end end
context 'when original folder does not exist anymore' do context 'when original folder does not exist anymore' do
...@@ -49,10 +55,14 @@ describe Projects::HashedStorage::MigrateAttachmentsService do ...@@ -49,10 +55,14 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
end end
it 'returns true' do 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 expect(service.execute).to be_truthy
end end
it 'sets skipped to true' do
service.execute
expect(service.skipped?).to be_truthy
end
end end
context 'when target folder already exists' do 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