diff --git a/main-site/photo-gallery-app/backend/scripts/reseed_uploads.js b/main-site/photo-gallery-app/backend/scripts/reseed_uploads.js index 90a691f..074f92d 100644 --- a/main-site/photo-gallery-app/backend/scripts/reseed_uploads.js +++ b/main-site/photo-gallery-app/backend/scripts/reseed_uploads.js @@ -48,11 +48,17 @@ async function main() { const baseName = path.basename(file, path.extname(file)); const caption = baseName.replace(/[-_]+/g, ' '); const tag = baseName.split('-')[1] || 'uncategorized'; + const tsMatch = file.match(/^(\d{13})-/); + const createdAt = tsMatch + ? new Date(parseInt(tsMatch[1])) + : fs.statSync(path.join(UPLOAD_DIR, file)).mtime; const doc = new Photo({ filename: file, path: path.join('uploads', file), caption, tags: [tag], + createdAt, + updatedAt: createdAt, }); await doc.save(); created++;