dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

File input directory type does not keep directory structure for files() and subsequently drops duplicates

Open rogusdev opened this issue 1 year ago • 2 comments

Problem

Using a directory / webkitdirectory file input to upload a directory, and then looping over the files() results, 2 things are broken:

  1. 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
  2. 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

rogusdev avatar Oct 28 '24 23:10 rogusdev

@cocos-robot run test cases

minggo avatar Oct 29 '24 06:10 minggo

⚠️ Package size ⤴ 179 bytes, old: 5430080, new: 5430259

Interface Check Report

This pull request does not change any public interfaces !

github-actions[bot] avatar Oct 29 '24 06:10 github-actions[bot]

@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

github-actions[bot] avatar Oct 29 '24 07:10 github-actions[bot]

@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

github-actions[bot] avatar Oct 29 '24 07:10 github-actions[bot]

@cocos-robot run test cases

minggo avatar Oct 29 '24 07:10 minggo

@cocos-robot run test cases

minggo avatar Oct 30 '24 01:10 minggo

@cocos-robot run test cases

sushanhong avatar Oct 30 '24 01:10 sushanhong

@cocos-robot run test cases

minggo avatar Oct 30 '24 05:10 minggo

@cocos-robot run test cases

sushanhong avatar Oct 30 '24 05:10 sushanhong

@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

github-actions[bot] avatar Oct 30 '24 08:10 github-actions[bot]

@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

Task Details

github-actions[bot] avatar Oct 30 '24 08:10 github-actions[bot]