5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-05-02 20:37:04 +00:00

Merge branch 'issue-12755' into 'rails'

fix: instalar las gemas cuando sea necesario #12755

See merge request sutty/sutty!130
This commit is contained in:
fauno 2023-04-10 15:27:46 +00:00
commit b65357cdec

View file

@ -554,10 +554,33 @@ class Site < ApplicationRecord
Dir.chdir path, &block
end
# Instala las gemas cuando es necesario:
#
# * El sitio existe
# * No están instaladas
# * El archivo Gemfile se modificó
# * El archivo Gemfile.lock se modificó
def install_gems
return unless persisted?
return if Rails.root.join('_storage', 'gems', name).directory?
deploys.find_by_type('DeployLocal').send(:bundle)
if !gem_dir? || gemfile_updated? || gemfile_lock_updated?
deploys.find_by_type('DeployLocal').send(:bundle)
touch
end
end
# Detecta si el repositorio de gemas existe
def gem_dir?
Rails.root.join('_storage', 'gems', name).directory?
end
# Detecta si el Gemfile fue modificado
def gemfile_updated?
updated_at < File.mtime(File.join(path, 'Gemfile'))
end
# Detecta si el Gemfile.lock fue modificado
def gemfile_lock_updated?
updated_at < File.mtime(File.join(path, 'Gemfile.lock'))
end
end