Commit 31fc5965 authored by Rémy Coutable's avatar Rémy Coutable

Monkey-patch Sprockets to prevent cache ballooning

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 97342325
# frozen_string_literal: true
Sprockets::Base.prepend(Gitlab::Patch::SprocketsBaseFileDigestKey)
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment