fix: reseed script now skips -sm and -md variant files
Previously all .webp files were indexed including thumbnails and medium variants, causing each photo to appear three times in the gallery. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2723a6d954
commit
633f1e2380
@ -37,7 +37,10 @@ async function main() {
|
|||||||
await mongoose.connect(MONGO_URI);
|
await mongoose.connect(MONGO_URI);
|
||||||
console.log('Connected to Mongo:', MONGO_URI);
|
console.log('Connected to Mongo:', MONGO_URI);
|
||||||
|
|
||||||
const files = fs.readdirSync(UPLOAD_DIR).filter(f => f.toLowerCase().endsWith('.webp'));
|
const files = fs.readdirSync(UPLOAD_DIR).filter(f => {
|
||||||
|
const lower = f.toLowerCase();
|
||||||
|
return lower.endsWith('.webp') && !lower.endsWith('-sm.webp') && !lower.endsWith('-md.webp');
|
||||||
|
});
|
||||||
let created = 0;
|
let created = 0;
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const existing = await Photo.findOne({ filename: file });
|
const existing = await Photo.findOne({ filename: file });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user