diff options
author | Rémy Coutable <remy@rymai.me> | 2019-01-30 12:28:39 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-02-05 13:38:52 +0100 |
commit | 31fc5965baf9ca23a1da4a0ffc350102fe4c89c6 (patch) | |
tree | 92e8e5de086bb718f9c2fb7da9ac06384eaa549e /lib/gitlab/patch/sprockets_base_file_digest_key.rb | |
parent | 9734232530ceb2268d3e894b36ce7d5543c56e51 (diff) | |
download | gitlab-ce-31fc5965baf9ca23a1da4a0ffc350102fe4c89c6.tar.gz |
Monkey-patch Sprockets to prevent cache ballooning
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib/gitlab/patch/sprockets_base_file_digest_key.rb')
-rw-r--r-- | lib/gitlab/patch/sprockets_base_file_digest_key.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/gitlab/patch/sprockets_base_file_digest_key.rb b/lib/gitlab/patch/sprockets_base_file_digest_key.rb new file mode 100644 index 00000000000..3925cdbbada --- /dev/null +++ b/lib/gitlab/patch/sprockets_base_file_digest_key.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +# This monkey patch prevent cache ballooning when caching tmp/cache/assets/sprockets +# on the CI. See https://github.com/rails/sprockets/issues/563 and +# https://github.com/rails/sprockets/compare/3.x...jmreid:no-mtime-for-digest-key. +module Gitlab + module Patch + module SprocketsBaseFileDigestKey + def file_digest(path) + if stat = self.stat(path) + digest = self.stat_digest(path, stat) + integrity_uri = self.hexdigest_integrity_uri(digest) + + key = Sprockets::UnloadedAsset.new(path, self).file_digest_key(integrity_uri) + cache.fetch(key) do + digest + end + end + end + end + end +end |