From 1706e87e9dcaa097a35864bc1a88b285e97b123e Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 29 Oct 2024 15:17:59 +0000 Subject: [PATCH] DEV: clear asset cache when plugins add/remove client.*.yml files (#29468) Our sprockets-based locale pipeline correctly `depends_on` client.*.yml files which already exist. But sprockets does not provide a way to watch for the creation of new files matching a certain path. This commit works around that limitation by adding the set of client.*.yml files to our global cache-clearing logic --- bin/unicorn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/unicorn b/bin/unicorn index 901fa70162a..4b5b6eb8659 100755 --- a/bin/unicorn +++ b/bin/unicorn @@ -23,7 +23,10 @@ def ensure_cache_clean! _all_plugin_directories = Pathname.new(RAILS_ROOT + '/plugins').children.select(&:directory?) core_git_sha = `git rev-parse HEAD`.strip plugins_combined_git_sha = `git ls-files -s plugins | git hash-object --stdin`.strip - super_sha = Digest::SHA1.hexdigest(core_git_sha + plugins_combined_git_sha) + client_locale_paths_digest = + Digest::SHA1.hexdigest(Dir.glob("#{RAILS_ROOT}/plugins/*/config/locales/client.*.yml").join) + super_sha = + Digest::SHA1.hexdigest(core_git_sha + plugins_combined_git_sha + client_locale_paths_digest) hash_file = "#{RAILS_ROOT}/tmp/plugin-hash" old_hash = File.exist?(hash_file) ? File.read(hash_file) : nil