Improve migration/rollback logic for attachments

This commit is contained in:
Gabriel Mazetto 2019-03-01 08:47:26 +01:00
parent 61d77a042d
commit 3524a618d6
2 changed files with 14 additions and 6 deletions

View file

@ -22,10 +22,14 @@ module Projects
@new_disk_path = project.disk_path @new_disk_path = project.disk_path
result = move_folder!(origin, target) result = move_folder!(origin, target)
if result
project.save! project.save!
if result && block_given? yield if block_given?
yield else
# Rollback changes
project.rollback!
end end
result result

View file

@ -17,10 +17,14 @@ module Projects
@new_disk_path = FileUploader.base_dir(project) @new_disk_path = FileUploader.base_dir(project)
result = move_folder!(origin, target) result = move_folder!(origin, target)
if result
project.save! project.save!
if result && block_given? yield if block_given?
yield else
# Rollback changes
project.rollback!
end end
result result