From 0e4461e957370418d2a8494ebee2762c6cfe8945 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 21 May 2026 11:29:11 -0400 Subject: [PATCH] fix: reseed sets createdAt from filename timestamp or file mtime Photos reseeded from disk now sort by their original upload time instead of all getting the same insertion timestamp. Co-Authored-By: Claude Sonnet 4.6 --- .../photo-gallery-app/backend/scripts/reseed_uploads.js | 6 ++++++ 1 file changed, 6 insertions(+) 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++;