Skip to content
Merged
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
4 changes: 3 additions & 1 deletion packages/web-app-files/src/HandleUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ export class HandleUpload extends BasePlugin<PluginOpts, OcUppyMeta, OcUppyBody>

if (!this.directoryTreeCreateEnabled) {
// if directory tree creation is disabled, we need to remove all folder files
// from the upload queue
// from the upload queue (both locally and from Uppy's state to prevent upload attempts)
const directoryFiles = filesToUpload.filter((file) => file.type === 'directory')
this.removeFilesFromUpload(directoryFiles)
filesToUpload = filesToUpload.filter((file) => file.type !== 'directory')
if (!filesToUpload.length) {
// if there are no files left to upload, we can clear the inputs and do nothing
Expand Down
9 changes: 9 additions & 0 deletions packages/web-app-files/tests/unit/HandleUpload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ describe('HandleUpload', () => {
await instance.handleUpload([mock<OcUppyFile>({ name: 'name' })])
expect(createDirectoryTreeSpy).not.toHaveBeenCalled()
})
it('removes directory dummy files from uppy queue when directory tree creation is disabled', async () => {
const { instance, mocks } = getWrapper({ directoryTreeCreateEnabled: false })
const removeFilesFromUploadSpy = vi.spyOn(instance, 'removeFilesFromUpload')
const directoryFile = mock<OcUppyFile>({ id: 'dir-1', name: 'emptyDir', type: 'directory' })
const regularFile = mock<OcUppyFile>({ id: 'file-1', name: 'file.txt' })
await instance.handleUpload([directoryFile, regularFile])
expect(removeFilesFromUploadSpy).toHaveBeenCalledWith([directoryFile])
expect(mocks.opts.uppyService.uploadFiles).toHaveBeenCalled()
})
})
})
})
Expand Down