Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions __tests__/uploader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
4 changes: 4 additions & 0 deletions lib/uploader/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Loading