Skip to content

Commit

Permalink
Added version for content hashes of the adblock components.
Browse files Browse the repository at this point in the history
  • Loading branch information
boocmp committed Jan 7, 2025
1 parent 6842fe2 commit 009cc31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ const generateSHA256HashOfFile = (file) => {
return generateSHA256Hash(fs.readFileSync(file))
}

const generateVersionedHashOfFile = (file, version) => {
return generateSHA256Hash(version + fs.readFileSync(file))
}

const getIDFromBase64PublicKey = (key) => {
const hash = crypto.createHash('sha256')
const data = Buffer.from(key, 'base64')
Expand Down
5 changes: 4 additions & 1 deletion scripts/packageAdBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ const processComponent = (

let contentHash
if (fileToHash !== undefined) {
// Increase this number if you want to recreate adblock components,
// even if the hash of the content file has not changed.
const contentHashVersion = 1
const contentFile = path.join('build', 'ad-block-updater', componentSubdir, fileToHash)
contentHash = util.generateSHA256HashOfFile(contentFile)
contentHash = util.generateVersionedHashOfFile(contentFile, contentHashVersion)
}

if (!localRun) {
Expand Down

0 comments on commit 009cc31

Please sign in to comment.