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>
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
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)
|
||||
return { ...result, ...publicLibrary(event, { light: true }) }
|
||||
// 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 }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user