fix: better handling of deletes and links

This commit is contained in:
2026-02-13 10:19:43 +01:00
parent b61dfd7b61
commit f904f42f88
13 changed files with 728 additions and 45 deletions

View File

@@ -507,7 +507,7 @@ export class MediaEngine extends EventEmitter {
async deleteMedia(id: string): Promise<boolean> {
const db = getDatabase().getLocal();
const existing = await db.select().from(media).where(eq(media.id, id)).get();
if (!existing) {
return false;
}
@@ -529,6 +529,10 @@ export class MediaEngine extends EventEmitter {
// Delete thumbnails
await this.deleteThumbnails(id);
// Delete post-media links (cascade cleanup)
const { postMedia } = await import('../database/schema');
await db.delete(postMedia).where(eq(postMedia.mediaId, id));
await db.delete(media).where(eq(media.id, id));
this.emit('mediaDeleted', id);