File input directory type does not keep directory structure for files() and subsequently drops duplicates
Problem
Using a directory / webkitdirectory file input to upload a directory, and then looping over the files() results, 2 things are broken:
- there is no folder structure with the filenames to identify where they came from per https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory#understanding_the_results
- because of 1, if there is a duplicate filename in another directory, the names collide and only one remains
Steps To Reproduce
input {
type: "file",
multiple: true,
directory: true,
onchange: move |evt| {
if let Some(file_engine) = evt.files() {
for filename in file_engine.files() {
log::warn!("filename {filename}");
}
}
},
}
Expected behavior
If you upload a folder "a", with structure like:
a/1.txt
a/o.txt
a/b/1.txt
a/b/2.txt
You will only see:
1.txt
o.txt
2.txt
Which has lost the second 1.txt, because it also lost the subdir "b" from the file paths.
Instead I would like to see:
a/1.txt
a/o.txt
a/b/1.txt
a/b/2.txt
Note that the initial "a/" is required, because a folder was uploaded, not simply files inside that folder!
Environment:
- Dioxus version: main
- App platform: web -- but probably applicable to all
Questionnaire
I'm interested in fixing this myself but don't know where to start
@cocos-robot run test cases
⚠️ Package size ⤴ 179 bytes, old: 5430080, new: 5430259
Interface Check Report
This pull request does not change any public interfaces !
@minggo, Please check the result of run test cases:
- Test Platform: PR-Test
- Editor Version: v3.8.5
- Task Result: FAIL
- Task URL: https://cctest.cocos.org/#/reportview/PR-TEST/12a19577-c9d0-4ef1-9931-e713bfcd5ae1/-1
- GitHub Action: https://github.com/cocos/cocos-engine/actions/runs/11568377571
Task Details
| Platform | build | boot | runned | crashScene | FailScene |
|---|---|---|---|---|---|
| web-mobile | PASS | PASS | FAIL | ||
| ios | PASS | PASS | FAIL | ||
| mac | PASS | PASS | FAIL | scroll-view-bounce-back,scroll-view-scroll-to-offset,pageView_free_horizontal,pageView_free_verticle,pageView_unified_horizontal,pageView_unified_verticle |
@minggo, Please check the result of run test cases:
- Test Platform: PR-Test
- Editor Version: v3.8.5
- Task Result: FAIL
- Task URL: https://cctest.cocos.org/#/reportview/PR-TEST/f0e60657-3226-4832-a260-3b099d6bf304/-1
- GitHub Action: https://github.com/cocos/cocos-engine/actions/runs/11568377571
Task Details
| Platform | build | boot | runned | crashScene | FailScene |
|---|---|---|---|---|---|
| windows | PASS | PASS | FAIL | scroll-view-bounce-back,scroll-view-scroll-to-offset,pageView_free_horizontal,pageView_free_verticle,pageView_unified_horizontal,pageView_unified_verticle | |
| android | PASS | PASS | FAIL | list-view,scroll-view-bounce-back,scroll-view-scroll-to-offset,pageView_free_horizontal,pageView_free_verticle,pageView_unified_horizontal,pageView_unified_verticle | |
| wechatgame | PASS | PASS | FAIL | scroll-view-bounce-back,scroll-view-scroll-to-offset,pageView_free_horizontal,pageView_free_verticle,pageView_unified_horizontal,pageView_unified_verticle |
@cocos-robot run test cases
@cocos-robot run test cases
@cocos-robot run test cases
@cocos-robot run test cases
@cocos-robot run test cases
@minggo, Please check the result of run test cases:
- Test Platform: PR-Test
- Editor Version: v3.8.5
- Task Result: PASS
- Task URL: https://cctest.cocos.org/#/reportview/PR-TEST/dc5c7121-8248-4bf7-9c25-cf7aa8dd0883/-1
- GitHub Action: https://github.com/cocos/cocos-engine/actions/runs/11587759590
Task Details
@minggo, Please check the result of run test cases:
- Test Platform: PR-Test
- Editor Version: v3.8.5
- Task Result: PASS
- Task URL: https://cctest.cocos.org/#/reportview/PR-TEST/17ef7472-6dc6-45d3-8a87-5610b017ca1c/-1
- GitHub Action: https://github.com/cocos/cocos-engine/actions/runs/11587759590