Commit 3524a618 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Improve migration/rollback logic for attachments

parent 61d77a04
...@@ -22,10 +22,14 @@ module Projects ...@@ -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
......
...@@ -17,10 +17,14 @@ module Projects ...@@ -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
......
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