mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 08:21:39 -06:00
fix(library): ignore current library during folder prescan
Prevent an edited library from treating its own persisted folders as conflicts while preserving overlap warnings for other libraries. Fixes #1340
This commit is contained in:
@@ -69,6 +69,24 @@ describe('useLibraryCreator', () => {
|
||||
expect(creator.prescanResult.value).toEqual(result)
|
||||
})
|
||||
|
||||
it('includes the current library ID when prescanning an edit', async () => {
|
||||
const { useLibraryCreator } = await import('../useLibraryCreator')
|
||||
const creator = useLibraryCreator()
|
||||
const result: PrescanResult = { paths: [{ path: '/books', accessible: true, fileCount: 2 }], totalFiles: 2 }
|
||||
apiMock.mockResolvedValue(jsonResponse(result))
|
||||
creator.initEdit(makeLibrary({ id: 12 }))
|
||||
|
||||
await creator.runPrescan()
|
||||
|
||||
expect(apiMock).toHaveBeenCalledWith(
|
||||
'/api/v1/libraries/prescan',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ paths: ['/books'], libraryId: 12 }),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('surfaces prescan connection failures', async () => {
|
||||
const { useLibraryCreator } = await import('../useLibraryCreator')
|
||||
const creator = useLibraryCreator()
|
||||
|
||||
@@ -141,10 +141,14 @@ export function useLibraryCreator() {
|
||||
prescanResult.value = null
|
||||
error.value = null
|
||||
try {
|
||||
const payload = {
|
||||
paths: form.folders,
|
||||
...(editingLibraryId.value === null ? {} : { libraryId: editingLibraryId.value }),
|
||||
}
|
||||
const res = await api('/api/v1/libraries/prescan', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ paths: form.folders }),
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
if (res.ok) {
|
||||
prescanResult.value = await res.json()
|
||||
|
||||
Reference in New Issue
Block a user