Skip to content

Commit

Permalink
Make asset_host affect watched_files_digest rather file name
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangarha committed Nov 7, 2023
1 parent e43d164 commit 88c833a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions lib/shakapacker/digest_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def watched_files_digest
end
files = Dir[*expanded_paths].reject { |f| File.directory?(f) }
file_ids = files.sort.map { |f| "#{File.basename(f)}/#{Digest::SHA1.file(f).hexdigest}" }
Digest::SHA1.hexdigest(file_ids.join("/"))

asset_host = Shakapacker.config.asset_host.to_s
Digest::SHA1.hexdigest(file_ids.join("/").concat(asset_host))
end

def record_compilation_digest
Expand All @@ -53,12 +55,7 @@ def record_compilation_digest
end

def compilation_digest_path
asset_host = Shakapacker.config.asset_host

path = "last-compilation-digest-#{Shakapacker.env}"
path += "-#{Digest::SHA1.hexdigest(asset_host)}" if asset_host.present?

config.cache_path.join(path)
config.cache_path.join("last-compilation-digest-#{Shakapacker.env}")
end
end
end
2 changes: 1 addition & 1 deletion spec/shakapacker/digest_strategy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def remove_compilation_digest_path

actual_path = @digest_strategy.send(:compilation_digest_path).basename.to_s
host_hash = Digest::SHA1.hexdigest("custom-path")
expected_path = "last-compilation-digest-#{Shakapacker.env}-#{host_hash}"
expected_path = "last-compilation-digest-#{Shakapacker.env}"

expect(actual_path).to eq expected_path
end
Expand Down

0 comments on commit 88c833a

Please sign in to comment.