From 8b5a39066fa25df157fb8a83292b3fc9a31cd88b Mon Sep 17 00:00:00 2001 From: Knight Date: Sat, 28 Dec 2024 10:33:40 -0500 Subject: [PATCH] Enhance debug logging in image fetching process to improve traceability of asset checks and downloads. Added logs for asset state, expected paths, and conditions for skipping existing files. --- fetchImages.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fetchImages.js b/fetchImages.js index 0fbc567..e805e8f 100644 --- a/fetchImages.js +++ b/fetchImages.js @@ -62,12 +62,20 @@ async function getAlbumAssets() { const fileName = `${asset.id}_${asset.originalFileName || 'untitled'}`; const outputPath = path.join(config.outputDir, fileName); + // Add debug logging to understand the state + console.log(`Checking asset ${asset.id}:`); + console.log(`- Expected path: ${outputPath}`); + // Check if file already exists and is in our metadata const existingImage = existingImages.find(img => img.id === asset.id); - if (existingImage && fs.existsSync(existingImage.localPath)) { - console.log(`Skipping existing file: ${fileName}`); - images.push(existingImage); - continue; + if (existingImage) { + console.log(`- Found in metadata: ${existingImage.localPath}`); + if (fs.existsSync(existingImage.localPath)) { + console.log(`- File exists on disk, skipping download`); + images.push(existingImage); + continue; + } + console.log(`- File not found on disk at ${existingImage.localPath}`); } console.log(`Downloading: ${fileName}`);