Delete library stills from disk before the catalog write, and stop caching their media.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-10-25 17:55:30 -05:00
co-authored by Cursor
parent 545a3d749b
commit 20359bfbd4
26 changed files with 635 additions and 247 deletions
+18 -6
View File
@@ -22,22 +22,34 @@ export function folderImageCount(folder, localStillCount = 0) {
return Number(localStillCount) || 0
}
/** Replace library rows from a wipe response. Rows already in the wiped folder stay gone. */
/** Cache-bust a library media URL. Always includes v so a pre-deploy cached URL is not reused. */
export function libraryMediaUrl(path, version) {
const base = String(path || '')
if (!base) return ''
const v = version == null || version === '' ? '0' : String(version)
const joiner = base.includes('?') ? '&' : '?'
return `${base}${joiner}v=${encodeURIComponent(v)}`
}
/** Replace library rows from a wipe response. Does not keep a suppression list. */
export function libraryAfterWipe(previous, response, folderId) {
const suppressed = new Set(previous?.suppressedIds || [])
const target = String(folderId || '')
for (const list of [previous?.stills, previous?.clips, previous?.tracks, response?.stills, response?.clips, response?.tracks]) {
const dropped = new Set(response?.deletedIds || [])
for (const list of [previous?.stills, previous?.clips, previous?.tracks]) {
for (const item of list || []) {
if (item?.id && String(item.folderId || '') === target) suppressed.add(item.id)
if (item?.id && String(item.folderId || '') === target) dropped.add(item.id)
}
}
const take = (list) => (Array.isArray(list) ? list : []).filter(item => item?.id && !suppressed.has(item.id))
const take = (list) => (Array.isArray(list) ? list : []).filter((item) => {
if (!item?.id || dropped.has(item.id)) return false
return String(item.folderId || '') !== target
})
return {
folders: Array.isArray(response?.folders) ? response.folders : (previous?.folders || []),
stills: take(response?.stills),
clips: take(response?.clips),
tracks: take(response?.tracks),
suppressedIds: [...suppressed]
suppressedIds: []
}
}