fix: drag&drop to upload with firefox produces wrong folder structure #719
Massimo Melina committed
Sep 21, 2024 at 10:40 UTC
3b20c439bb0d5a95a8364e1ba23c78a1d1c7eaa4
1 file changed
+3
-2
frontend/src/upload.ts
+3
-2
@@ -465,10 +465,11 @@ export function acceptDropFiles(cb: false | undefined | ((files:File[], to: stri
465
if (entry)
466
(function recur(entry: FileSystemEntry, to = '') {
467
if (entry.isFile)
468
- (entry as FileSystemFileEntry).file(x => cb([x], to))
468
+ (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
469
else (entry as FileSystemDirectoryEntry).createReader?.().readEntries(entries => {
470
+ const newTo = to + entry.name + '/'
471
for (const e of entries)
471
- recur(e, to + entry.name + '/')
472
+ recur(e, newTo)
473
})
474
})(entry)
475
}