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:
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { folderImageCount, libraryAfterWipe, mergeLibraryRows, replaceLibraryRows } from '../shared/studio2/viewer.mjs'
|
||||
import { folderImageCount, libraryAfterWipe, libraryMediaUrl, mergeLibraryRows, replaceLibraryRows } from '../shared/studio2/viewer.mjs'
|
||||
|
||||
test('folderImageCount trusts a server count of 0', () => {
|
||||
assert.equal(folderImageCount({ id: 'inbox', imageCount: 0 }, 1762), 0)
|
||||
@@ -8,7 +8,14 @@ test('folderImageCount trusts a server count of 0', () => {
|
||||
assert.equal(folderImageCount(undefined, 3), 3)
|
||||
})
|
||||
|
||||
test('libraryAfterWipe replaces state and does not keep wiped folder rows from a stale list', () => {
|
||||
test('libraryMediaUrl always changes the pre-deploy cache key', () => {
|
||||
assert.equal(libraryMediaUrl('/api/library/stills/abc/thumb', 0), '/api/library/stills/abc/thumb?v=0')
|
||||
assert.equal(libraryMediaUrl('/api/library/stills/abc/preview', 4), '/api/library/stills/abc/preview?v=4')
|
||||
assert.equal(libraryMediaUrl('/api/library/clips/abc/first-frame?thumb=1', 2), '/api/library/clips/abc/first-frame?thumb=1&v=2')
|
||||
assert.notEqual(libraryMediaUrl('/api/library/stills/abc/thumb', 0), '/api/library/stills/abc/thumb')
|
||||
})
|
||||
|
||||
test('libraryAfterWipe replaces the folder from the response and does not keep a suppression list', () => {
|
||||
const previous = {
|
||||
folders: [{ id: 'inbox', imageCount: 2 }],
|
||||
stills: [{ id: 'new-1', folderId: 'inbox' }, { id: 'new-2', folderId: 'inbox' }],
|
||||
@@ -24,16 +31,16 @@ test('libraryAfterWipe replaces state and does not keep wiped folder rows from a
|
||||
{ id: 'kept', folderId: 'other' }
|
||||
],
|
||||
clips: [{ id: 'clip-ghost', folderId: 'inbox' }],
|
||||
tracks: []
|
||||
tracks: [],
|
||||
deletedIds: ['new-1', 'new-2']
|
||||
}
|
||||
const next = libraryAfterWipe(previous, stale, 'inbox')
|
||||
assert.deepEqual(next.stills.map(item => item.id), ['kept'])
|
||||
assert.deepEqual(next.clips, [])
|
||||
assert.equal(next.folders[0].imageCount, 0)
|
||||
assert.equal(next.suppressedIds.includes('new-1'), true)
|
||||
assert.equal(next.suppressedIds.includes('ghost'), true)
|
||||
assert.equal(next.suppressedIds.includes('already-gone'), true)
|
||||
const page = mergeLibraryRows(next.stills, stale.stills, next.suppressedIds)
|
||||
assert.deepEqual(page.map(item => item.id), ['kept'])
|
||||
assert.deepEqual(replaceLibraryRows(stale.stills, next.suppressedIds).map(item => item.id), ['kept'])
|
||||
assert.deepEqual(next.suppressedIds, [])
|
||||
const replaced = replaceLibraryRows(next.stills, [])
|
||||
assert.deepEqual(replaced.map(item => item.id), ['kept'])
|
||||
const page = mergeLibraryRows(replaced, [{ id: 'kept', folderId: 'other' }, { id: 'fresh', folderId: 'other' }], [])
|
||||
assert.deepEqual(page.map(item => item.id), ['kept', 'fresh'])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user