From 7e0ab59ffa5d2b53239f18cee6324c14bd57918e Mon Sep 17 00:00:00 2001 From: jazzari Date: Tue, 17 Oct 2023 14:36:34 -0300 Subject: [PATCH] fix: arreglado rescue que devuelve el repositorio a su estado original #13077 --- app/services/site_service.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 90a4a339..532d48ac 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -88,14 +88,16 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do end def rename(name) + moved = false Site.transaction do + raise ActiveRecord::Rollback if site.path site.name = name - raise ActiveRecord::Rollback if File.exists?(name) - FileUtils.mv site.path_was, site.path unless 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 + moved = true rescue StandardError - FileUtils.mv site.path, site.path_was if File.exists?(name) + FileUtils.mv (site.path, site.path_was) if moved raise end end