Files
TowstyandCursor 545a3d749b Stop a folder wipe from restoring the pre-wipe library catalog.
The in-memory catalog could outlive the write, so delete-all came back as thousands of empty tiles and a stale badge.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-24 12:01:25 -05:00

15 lines
770 B
TypeScript

import { assertFolderAccess, assertLibraryOwner, invalidateCatalogCache, publicLibrary, publicLibraryPage, wipeFolderContents } from '~/server/utils/library'
export default defineEventHandler(async (event) => {
const { owner } = assertLibraryOwner(event)
const id = String(getRouterParam(event, 'id') || '')
assertFolderAccess(event, id)
const result = await wipeFolderContents(owner, id)
// wipeFolderContents already drops the cache. Drop it again so this read
// cannot reuse a catalog object captured before the write.
invalidateCatalogCache(owner)
const library = publicLibrary(event, { light: true })
const page = publicLibraryPage(event, { folderId: id, limit: 50 })
return { ...result, ...library, page, folderId: result.folderId || id }
})