feat: Implement is_deleted flag for items, add new utility scripts, and refine UI styles.
This commit is contained in:
40
debug/fix_deleted.mjs
Normal file
40
debug/fix_deleted.mjs
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
import db from "../src/inc/sql.mjs";
|
||||
import { promises as fs } from "fs";
|
||||
|
||||
(async () => {
|
||||
console.log("Starting migration...");
|
||||
const items = await db`select id, dest from items where active = false`;
|
||||
console.log(`Found ${items.length} inactive items.`);
|
||||
|
||||
let trashCount = 0;
|
||||
let pendingCount = 0;
|
||||
let brokenCount = 0;
|
||||
|
||||
for (const item of items) {
|
||||
try {
|
||||
await fs.access(`./deleted/b/${item.dest}`);
|
||||
// File exists in deleted, mark as is_deleted = true
|
||||
await db`update items set is_deleted = true where id = ${item.id}`;
|
||||
trashCount++;
|
||||
} catch {
|
||||
// Not in deleted, check public
|
||||
try {
|
||||
await fs.access(`./public/b/${item.dest}`);
|
||||
// In public, is_deleted = false (default)
|
||||
pendingCount++;
|
||||
} catch {
|
||||
// Not in either? Broken.
|
||||
console.log(`Item ${item.id} (${item.dest}) missing from both locations.`);
|
||||
brokenCount++;
|
||||
// Default is false, which effectively puts it in pending queue as 'broken'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Migration complete.`);
|
||||
console.log(`Trash (soft-deleted): ${trashCount}`);
|
||||
console.log(`Pending: ${pendingCount}`);
|
||||
console.log(`Broken: ${brokenCount}`);
|
||||
process.exit(0);
|
||||
})();
|
||||
Reference in New Issue
Block a user