diff --git a/lib/util.js b/lib/util.js index 326aa9ec..fae53832 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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') diff --git a/scripts/packageAdBlock.js b/scripts/packageAdBlock.js index ea013bfe..cd715a4e 100644 --- a/scripts/packageAdBlock.js +++ b/scripts/packageAdBlock.js @@ -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) {