let copy_r = async function (src, dest) { let exists = fs.existsSync(src); let stats = exists && await fsp.stat(src); let isDirectory = exists && stats.isDirectory(); if (exists && isDirectory) { await fsp.mkdir(dest); for (const i of (await fsp.readdir(src)).values()) { await copy_r(path.join(src, i), path.join(dest, i)) } } else await fsp.copyFile(src, dest); }
root.append(newSmallListItem({ label: "Choose a new wallpaper", sublabel: "From local storage", click() { Shell.selectFile(Shell.ACTION_OPEN).then(file => { fs.promises.copyFile(file, wpFile).then(e => { new Snackbar("Wallpaper have been changed"); }); }); } }));
Promise.map( evaluatedImages.filter(evaluatedImage => !evaluatedImage.error), async ({ image, card }, index) => { if (index % 100 === 1) { console.log(` ${index + 1}`) } const extname = path.extname(image.file) const dest = path.join(triagePath, `/${card.identifier}${extname.toLowerCase()}`) const srcSize = await fs.stat(image.file).then(stat => stat.size).catch(() => 0) const destSize = await fs.stat(dest).then(stat => stat.size).catch(() => 0) if (srcSize !== destSize) { return fs.copyFile(image.file, dest) } return null }, { concurrency: 10 } )
} else { await fs.copyFile(src, dest); console.log(`File ${file} copied`);
await fsp.copyFile(src, dest); copied++; };
Promise.map( evaluatedImages.filter(evaluatedImage => !evaluatedImage.error), async ({ image, card }, index) => { if (index % 100 === 1) { console.log(` ${index + 1}`) } const extname = path.extname(image.file) const dest = path.join(triagePath, `/${card.identifier}${extname.toLowerCase()}`) const srcSize = await fs.stat(image.file).then(stat => stat.size).catch(() => 0) const destSize = await fs.stat(dest).then(stat => stat.size).catch(() => 0) if (srcSize !== destSize) { return fs.copyFile(image.file, dest) } return null }, { concurrency: 10 } )