From e266b88866dd5c4a5bf29f1164ab16aaa3a2cbcd Mon Sep 17 00:00:00 2001 From: f Date: Wed, 15 May 2024 17:25:10 -0300 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20instalar=20gemas=20si=20la=20plantil?= =?UTF-8?q?la=20no=20est=C3=A1=20instalada=20#16282?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site.rb | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index 377c6b35..28f0d739 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -577,20 +577,37 @@ class Site < ApplicationRecord def install_gems return unless persisted? - Site.one_at_a_time.synchronize do - deploy_local = deploys.find_by_type('DeployLocal') - deploy_local.git_lfs - end + deploy_local = deploys.find_by_type('DeployLocal') + deploy_local.git_lfs - return unless !gems_installed? || gemfile_updated? || gemfile_lock_updated? + return unless (!gems_installed? || theme_path.blank?) || gemfile_updated? || gemfile_lock_updated? - Site.one_at_a_time.synchronize do - deploy_local.bundle - touch - FileUtils.touch(gemfile_path) - end + deploy_local.bundle + touch + FileUtils.touch(gemfile_path) end + # El sitio tiene una plantilla + # + # @return [Bool] + def theme? + config.key?('theme') + end + + # El directorio donde se encuentran los archivos de la plantilla. Si + # es nil es que las dependencias todavía no se instalaron. + # + # @return [String,nil] + def theme_path + @theme_path ||= + if theme? + Dir[gem_path.join('gems', "#{config['theme']}-*").to_s].first + else + path + end + end + + # @return [Pathname] def gem_path @gem_path ||= begin From 5e99cb4758447e7d53d4c41924ec1ba479e2512f Mon Sep 17 00:00:00 2001 From: f Date: Wed, 15 May 2024 17:26:14 -0300 Subject: [PATCH 2/2] fix: no correr git lfs al cargar el sitio es muy lento --- app/models/site.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index 28f0d739..75b0a744 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -576,13 +576,9 @@ class Site < ApplicationRecord # * El archivo Gemfile.lock se modificó def install_gems return unless persisted? - - deploy_local = deploys.find_by_type('DeployLocal') - deploy_local.git_lfs - return unless (!gems_installed? || theme_path.blank?) || gemfile_updated? || gemfile_lock_updated? - deploy_local.bundle + deploys.find_by_type('DeployLocal').bundle touch FileUtils.touch(gemfile_path) end