Skip to content

Commit

Permalink
fix(get): do not check integrity of community ffmpeg but give a warni…
Browse files Browse the repository at this point in the history
…ng (#1253)

Refs: #1209
  • Loading branch information
ayushmanchhabra authored Oct 2, 2024
1 parent ac2d603 commit 0c05a34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/get/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ async function get(options) {
`${options.downloadUrl}/v${options.version}/SHASUMS256.txt`,
`${options.cacheDir}/shasum/${options.version}.txt`,
options.cacheDir,
options.ffmpeg,
);

if (options.ffmpeg === true) {
Expand Down
9 changes: 7 additions & 2 deletions src/get/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import util from '../util.js';
* @param {string} shaUrl - URL to get the shasum text file from.
* @param {string} shaOut - File path to shasum text file.
* @param {string} cacheDir - File path to cache directory.
* @param {ffmpeg} ffmpeg - Toggle between community (true) and official (false) ffmpeg binary
* @throws {Error}
* @returns {Promise<boolean>} - Returns true if the checksums match.
*/
export default async function verify(shaUrl, shaOut, cacheDir) {
export default async function verify(shaUrl, shaOut, cacheDir, ffmpeg) {
const shaOutExists = await util.fileExists(shaOut);

if (shaOutExists === false) {
Expand All @@ -38,7 +39,11 @@ export default async function verify(shaUrl, shaOut, cacheDir) {
hash.update(fileBuffer);
const generatedSha = hash.digest('hex');
if (storedSha !== generatedSha) {
throw new Error(`SHA256 checksums do not match. The file ${filePath} expected shasum is ${storedSha} but the actual shasum is ${generatedSha}.`);
if (filePath.includes('ffmpeg') && ffmpeg) {
console.warn(`The generated shasum for the community ffmpeg at ${filePath} is ${generatedSha}. The integrity of this file should be manually verified.`);
} else {
throw new Error(`SHA256 checksums do not match. The file ${filePath} expected shasum is ${storedSha} but the actual shasum is ${generatedSha}.`);
}
}
}
}
Expand Down

0 comments on commit 0c05a34

Please sign in to comment.