From 1675e32fe84556afdc45bea9837a1773623c1f4b Mon Sep 17 00:00:00 2001 From: jazzari Date: Mon, 9 Oct 2023 15:50:25 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20agregado=20bloque=20de=20excepci=C3=B3n?= =?UTF-8?q?=20en=20metodo=20rename=20#13077?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/site_service.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 5522245a..90a4a339 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -90,9 +90,13 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do def rename(name) Site.transaction do site.name = name - FileUtils.mv site.path_was, site.path(name: name) + raise ActiveRecord::Rollback if File.exists?(name) + FileUtils.mv site.path_was, site.path unless File.exists?(name) ActiveStorage::Blob.where(service_name: site.name_was).update_all(service_name: site.name) site.save + rescue StandardError + FileUtils.mv site.path, site.path_was if File.exists?(name) + raise end end