diff --git a/__tests__/uploader.spec.ts b/__tests__/uploader.spec.ts index 0964ddc5..cb3fd6fc 100644 --- a/__tests__/uploader.spec.ts +++ b/__tests__/uploader.spec.ts @@ -122,4 +122,19 @@ describe('Uploader', () => { expect(() => { uploader.destination = newDestination as unknown as nextcloudFiles.Folder }).toThrowError(/invalid destination/i) }) }) + + describe('batchUpload', () => { + test('No upload when skipping all in conflict picker', async () => { + const uploader = new Uploader() + await uploader.batchUpload('/', [new File([], 'file.txt')], () => Promise.resolve([])) + vi.spyOn(uploader, 'upload') + expect(uploader.upload).not.toHaveBeenCalled() + }) + + test('Empty queue when skipping all in conflict picker', async () => { + const uploader = new Uploader() + await uploader.batchUpload('/', [new File([], 'file.txt')], () => Promise.resolve([])) + expect(uploader.queue).toHaveLength(0) + }) + }) }) diff --git a/lib/uploader/uploader.ts b/lib/uploader/uploader.ts index d2584ea0..0f96c43e 100644 --- a/lib/uploader/uploader.ts +++ b/lib/uploader/uploader.ts @@ -326,6 +326,10 @@ export class Uploader { reject(error) } } finally { + // Upload queue is cleared when all the uploading jobs are done + // Meta upload unlike real uploading does not create a job + // Removing it manually here to make sure it is remove even when no uploading happened and there was nothing to finish + this._uploadQueue.splice(this._uploadQueue.indexOf(upload), 1) this._notifyAll(upload) this.updateStats() }