From ad7f55adf73a1fb0c27ed8473d982e7c0e2d3fba Mon Sep 17 00:00:00 2001 From: f Date: Tue, 26 Mar 2024 12:44:07 -0300 Subject: [PATCH] chore: rubocop --- app/services/site_service.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/services/site_service.rb b/app/services/site_service.rb index d148185a..8c0a6833 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -89,19 +89,21 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do end def rename(name) - return if name == site.name + return if name == site.name + moved = false - site.name = name + site.name = name Site.transaction do - raise ActiveRecord::Rollback if File.exists?(site.path) + raise ActiveRecord::Rollback if File.exist?(site.path) + FileUtils.mv(site.path_was, site.path) moved = true 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 moved - raise + rescue StandardError + FileUtils.mv(site.path, site.path_was) if moved + raise end end @@ -239,9 +241,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do end end - private - - def with_all_locales(&block) + def with_all_locales site.locales.map do |locale| next unless I18n.available_locales.include? locale