Track when MigrateAttachmentsService is skipped
We need this new state for the Geo event logic in EE
This commit is contained in:
parent
7bc16889df
commit
02ac66de90
2 changed files with 18 additions and 2 deletions
|
@ -12,6 +12,7 @@ module Projects
|
|||
@logger = logger || Rails.logger
|
||||
@old_disk_path = old_disk_path
|
||||
@new_disk_path = project.disk_path
|
||||
@skipped = false
|
||||
end
|
||||
|
||||
def execute
|
||||
|
@ -32,11 +33,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
|
||||
|
|
Loading…
Reference in a new issue