From de041461e37cac866c20c70df37f70b460c86a9e Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Sat, 7 May 2022 21:57:42 +0200 Subject: [PATCH] --force & --quiet flag --- src/sync.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/sync.js b/src/sync.js index 80b5483..00dc446 100644 --- a/src/sync.js +++ b/src/sync.js @@ -16,7 +16,9 @@ const argsConfig = { path: args.length > 0 && !args[0].startsWith("--") ? args[0] : "./album", downloadVideo: false, //args.includes("--video") not implemented, downloadRaw: args.includes("--raw"), - removeOld: args.includes("--cleanup") + removeOld: args.includes("--cleanup"), + forceDownload: args.includes("--force"), + quiet: args.includes("--quiet") } argsConfig.path = path.resolve(argsConfig.path); @@ -76,8 +78,8 @@ async function syncImage(imageObject) { filesBefore.splice(idx, 1); } - if (fs.existsSync(filepath)) { - console.log(`Skipping ${filename} (already exists)`); + if (!argsConfig.forceDownload && fs.existsSync(filepath)) { + if (!argsConfig.quiet) console.log(`Skipping ${filename} (already exists)`); return }; @@ -151,13 +153,13 @@ async function updateAlbumData() { const data = await response.json(); nextPageToken = data.nextPageToken; - console.log(`Downloading images ${runs * 100 + 1} to ${runs * 100 + data.mediaItems.length}... (of ${secrets.album.count})`); + if (!argsConfig.quiet) console.log(`Downloading images ${runs * 100 + 1} to ${runs * 100 + data.mediaItems.length}... (of ${secrets.album.count})`); await downloadList(data.mediaItems); } while (nextPageToken); if (argsConfig.removeOld) { - console.log("Removing old files..."); + if (!argsConfig.quiet) console.log("Removing old files..."); for (const file of filesBefore) { fs.unlinkSync(path.resolve(argsConfig.path, file)); }