Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Picking a folder in iOS causes the original folder to be deleted. #1412

Closed
1 of 4 tasks
twinkles-twinstar opened this issue Nov 24, 2023 · 9 comments
Closed
1 of 4 tasks
Labels
new issue An issue that hasn't yet been seen from the maintainer stale

Comments

@twinkles-twinstar
Copy link
Contributor

twinkles-twinstar commented Nov 24, 2023

Describe the bug
This is a serious bug where users' files are deleted without them noticing. If use file_picker version 5.3.3 or higher, when an ios user picks a directory, the original directory will be deleted (actually, moved to the app's sandbox tmp directory, and the user cannot access them), and file_picker returns a path in tmp directory.
In 5.3.2 and earlier versions, file_picker will return the real absolute path of the original directory.
This BUG looks to be caused by this pull: #1311 (I'm not an ios programmer so I don't know how to fix this bug...), which moves the file or directory pointed to by the original url into the tmp directory; please restore the previous behavior (5.3.2, getting the original absolute path, which is the best, I think ?), or copy the directory to tmp (rather than moving it).

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
iOS 16.5

How are you picking?

if (Platform.isIOS) {
  var selection = await FilePicker.platform.getDirectoryPath();
  result = selection;
}

Details to reproduce the issue

  1. open a directory picker.
  2. select a directory.
  3. the selected directory was deleted (moved to the <application-sandbox-directory>/tmp directory).
  4. file_picker returnd the tmp path.

Error Log
None.

Screenshots and/or video
None.

Flutter Version details
Flutter 3.16, no probrlm.

Additional context
None.

@twinkles-twinstar twinkles-twinstar added the new issue An issue that hasn't yet been seen from the maintainer label Nov 24, 2023
Copy link

github-actions bot commented Dec 2, 2023

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Dec 2, 2023
@bypass112
Copy link

Can conform, I tried to select "AAA" folder and my app crashed with the following error:
“Aaa” couldn’t be moved because you don’t have permission to access “tmp”.
After downgrading to 5.3.2 it works again.

@github-actions github-actions bot removed the stale label Dec 7, 2023
@mateusz-bak
Copy link

Observed the same issue on 6.1.1

Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale label Dec 17, 2023
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

@mateusz-bak
Copy link

Please reopen

@twinkles-twinstar
Copy link
Contributor Author

I created a fork to fix this issue: twinkles-twinstar/flutter_file_picker .
When the user selects a directory, the picker will return its absolute path (/private/var/....) and will not delete the original directory.
BTW, it seems that it is possible to return the absolute path (/private/var/....) when selecting a file. I don't know if this path can be accessed in swift/objc/dart (I am not an ios developer and don't know much about the filesystem policy for ios), but I was able to operate it using c++ filesystem/fopen, if you need absolute paths, you can imitate my CustomMethodChannel.

@Louis-He
Copy link

Louis-He commented Mar 7, 2024

I think we should reopen this issue since the package is mostly unusable if someone needs to use this plugin to select a folder.

@wonli
Copy link

wonli commented Apr 20, 2024

Are there other alternative packages available?

navaronbracke added a commit that referenced this issue Apr 22, 2024
fix #1412: Picking a folder in iOS causes the original folder to be deleted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue An issue that hasn't yet been seen from the maintainer stale
Projects
None yet
Development

No branches or pull requests

5 participants