Keep uploaded images in folders by what they're for
logos/ for logo and icon fields, thumbnails/ for previews the site saves (link previews, Drive first pages), images/ for everything else; each small copy beside its image. Images from before folders are sorted once at boot by their uses, and every record naming them is rewritten in one transaction after the files move. The Media page and image pickers get a tab per folder; a picker opens on its field's folder and uploads there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4b249c9e52
commit
9854da965e
14 changed files with 283 additions and 51 deletions
|
|
@ -37,6 +37,7 @@ import { bodyLimit } from "hono/body-limit";
|
|||
import { requireAuth, requireRole } from "../auth.js";
|
||||
import { driveDelete, driveList, driveReady, driveShareWithAnyone, driveThumbnail, driveUpload } from "../googleService.js";
|
||||
import { addToLibrary, recordsNaming } from "./media.js";
|
||||
import { publicPath } from "../media.js";
|
||||
import { NO_STORE } from "../shape.js";
|
||||
|
||||
const files = new Hono();
|
||||
|
|
@ -100,8 +101,8 @@ function fetchPreview(db, row, userId) {
|
|||
try {
|
||||
const image = await driveThumbnail(row.drive_id);
|
||||
if (image) {
|
||||
const saved = await addToLibrary(db, image, { originalName: `${shape(row).title} (preview)`, userId });
|
||||
db.prepare(`UPDATE drive_files SET preview = ? WHERE id = ?`).run(`/uploads/${saved.filename}`, row.id);
|
||||
const saved = await addToLibrary(db, image, { originalName: `${shape(row).title} (preview)`, userId, folder: "thumbnails" });
|
||||
db.prepare(`UPDATE drive_files SET preview = ? WHERE id = ?`).run(publicPath(saved.filename), row.id);
|
||||
return;
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue