Skip to content

Uploading a mix of files and folders changes directory structure #76

@campbellwray

Description

@campbellwray

Describe the bug
When uploading a mix of files and folders, if the browser decides to process the folder first, the subsequent files will be placed into that folder.

For example:

foo/bar.txt
foo.txt

Can result in

foo/bar.txt
foo/foo.txt

To Reproduce
Steps to reproduce the behavior:

  1. Select a series of files and folders
  2. Drag and drop them into the uploader
  3. Occasionally the files will end up in the same folder

This isn't guaranteed to work, if the top level files are processed first then the upload will work as expected. I'm not sure how the browser decides the order that it processes the dropped files, but in my testing it isn't alphabetical.

Expected behavior
Top level files should not be added to a folder

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Safari

Additional context
This seems to be related to how rootFolderName is set. It seems like null should be an acceptable value, but it doesn't appear to get set back to null once it is set.

For example I'm not sure why the following if statement exists:

// If this is the first file and we don't have a root folder name yet,
// use its parent folder name
if (!rootFolderName && path) {
    rootFolderName = path.split('/')[0];
    console.debug('Set root folder name from file path:', rootFolderName);
}

In my testing making this non-conditional fixes the issue, i.e. just have:

rootFolderName = path.split('/')[0];
console.debug('Set root folder name from file path:', rootFolderName);

But I don't want to remove it without understanding its purpose.

I am happy to open a PR with this fix if someone more familiar with the project can confirm that it will not have unintended consequences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions