Skip existing mining pool logos when syncing assets

This commit is contained in:
softsimon 2023-04-19 13:10:49 +04:00
parent 97c8ace8f7
commit 7f3e4eb534
No known key found for this signature in database
GPG key ID: 488D7DCFB5A430D7

View file

@ -56,9 +56,15 @@ function downloadMiningPoolLogos() {
let response_body = Buffer.concat(chunks_of_data);
try {
const poolLogos = JSON.parse(response_body.toString());
let downloadedCount = 0;
for (const poolLogo of poolLogos) {
download(`${PATH}/mining-pools/${poolLogo.name}`, poolLogo.download_url);
const filePath = `${PATH}/mining-pools/${poolLogo.name}`;
if (!fs.existsSync(filePath)) {
download(filePath, poolLogo.download_url);
downloadedCount++;
}
}
console.log(`Downloaded ${downloadedCount} and skipped ${poolLogos.length - downloadedCount} existing mining pool logos`);
} catch (e) {
console.error(`Unable to download mining pool logos. Trying again at next restart. Reason: ${e instanceof Error ? e.message : e}`);
}