fix: drag&drop to upload with firefox produces wrong folder structure #719
Massimo Melina committed
Sep 21, 2024 at 10:40 UTC
0d7fe4927457b954ce34c54eae20c8ceb3864ed5
1 file changed
+3
-2
frontend/src/upload.ts
+3
-2
@@ -481,10 +481,11 @@ export function acceptDropFiles(cb: false | undefined | ((files:File[], to: stri
481
if (entry)
482
(function recur(entry: FileSystemEntry, to = '') {
483
if (entry.isFile)
484
- (entry as FileSystemFileEntry).file(x => cb([x], to))
484
+ (entry as FileSystemFileEntry).file(x => cb([x], x.webkitRelativePath ? '' : to)) // ff130 fills webkitRelativePath when dropping a folder, while chrome128 doesn't and we pass 'to' to preserve the structure
485
else (entry as FileSystemDirectoryEntry).createReader?.().readEntries(entries => {
486
+ const newTo = to + entry.name + '/'
487
for (const e of entries)
487
- recur(e, to + entry.name + '/')
488
+ recur(e, newTo)
489
})
490
})(entry)
491
}