Skip to content

Commit

Permalink
Add error handling to logo hash calculation in version check script
Browse files Browse the repository at this point in the history
  • Loading branch information
hiletmis committed Nov 8, 2024
1 parent d3f3050 commit 49fc16d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions scripts/version-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,20 @@ function getLogoList(mode) {
}

async function calcHash(dir, file) {
const fileBuffer = await fs.readFile(`${dir}/${file}`);

//hash 2 times to get the same hash as dropbox
const hashSum1 = crypto.createHash('sha256');
hashSum1.update(fileBuffer);
const hex = hashSum1.digest('hex');
const binary = Buffer.from(hex, 'hex');
const hashSum2 = crypto.createHash('sha256');
hashSum2.update(binary);
return hashSum2.digest('hex');
try {
const fileBuffer = await fs.readFile(`${dir}/${file}`);
//hash 2 times to get the same hash as dropbox
const hashSum1 = crypto.createHash('sha256');
hashSum1.update(fileBuffer);
const hex = hashSum1.digest('hex');
const binary = Buffer.from(hex, 'hex');
const hashSum2 = crypto.createHash('sha256');
hashSum2.update(binary);
return hashSum2.digest('hex');
} catch (error) {
console.error(error);
return '';
}
}

async function getLogoFileHashes(dir, mode) {
Expand Down

0 comments on commit 49fc16d

Please sign in to comment.