Sha256: 9db1986dcc18075a069cf520fce114a025b7afbbf26a352924cb7b6322c91c63
Contents?: true
Size: 1.55 KB
Versions: 4
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true module ShopifyCLI module Theme class Syncer class Checksums def initialize(theme) @theme = theme @checksum_by_key = {} # Mutex used to coordinate changes in the checksums (shared accross `Syncer` threads) @checksums_mutex = Mutex.new end def has?(file) checksum_by_key.key?(to_key(file)) end def file_has_changed?(file) file.checksum != checksum_by_key[file.relative_path] end def delete(file) checksums_mutex.synchronize do checksum_by_key.delete(to_key(file)) end end def keys checksum_by_key.keys end def [](key) checksum_by_key[key] end def []=(key, value) checksums_mutex.synchronize do checksum_by_key[key] = value end end # Generate .liquid asset files are reported twice in checksum: # once of generated, once for .liquid. We only keep the .liquid, that's the one we have # on disk. def reject_duplicated_checksums! checksums_mutex.synchronize do checksum_by_key.reject! { |key, _| checksum_by_key.key?("#{key}.liquid") } end end private def to_key(file) theme[file].relative_path end # Private getters only used in unit tests attr_reader :checksum_by_key attr_reader :theme attr_reader :checksums_mutex end end end end
Version data entries
4 entries across 4 versions & 1 rubygems