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

FilePicker.platform.getDirectoryPath() seems to be moving the original directory to tmp directory [IOS] #1440

Open
1 of 4 tasks
hasanmhallak opened this issue Jan 29, 2024 · 35 comments
Assignees
Labels
iOS Issue applies to iOS platform needs investigation triage Further information is requested

Comments

@hasanmhallak
Copy link

hasanmhallak commented Jan 29, 2024

Describe the bug
It seems like the FilePicker.platform.getDirectoryPath() will move the original directory instead of copying it to tmp/cache directory.

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
IOS 17.2

How are you picking?

final path = await FilePicker.platform.getDirectoryPath();
       print(path);

Details to reproduce the issue
Try to use FilePicker.platform.getDirectoryPath() on any directory.

Error Log
N/A

Screenshots and/or video

Screen.Recording.2024-01-29.at.10.16.31.AM-1.mov

Flutter Version details

[✓] Flutter (Channel stable, 3.16.4, on macOS 13.5.2 22G91 darwin-arm64, locale
    en-EG)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[!] Android Studio (version unknown)
    ✗ Unable to determine Android Studio version.
    ✗ Unable to find bundled Java version.
[✓] VS Code (version 1.85.2)
[✓] Connected device (3 available)
[✓] Network resources

Additional context
When invoking FilePicker.platform.getDirectoryPath(); on Android, it successfully returns the actual path of any selected directory.

However, on iOS, due to the limitations you've outlined in your FAQ, one must copy the file or directory to a temporary directory for access.

An issue arises with FilePicker.platform.getDirectoryPath(); on iOS, where it moves the directory instead of copying it, contrary to the expected behavior. As a result, the user will permanently lose access to that directory.

@hasanmhallak hasanmhallak added the new issue An issue that hasn't yet been seen from the maintainer label Jan 29, 2024
@Reyrey14-1
Copy link

same here. any update on the issue?

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 Feb 10, 2024
@ElHyperion
Copy link

ElHyperion commented Feb 14, 2024

The FilePicker works fine on Android but on iOS it crashes my app with no permission to access "tmp", whether I want to pick an internal directory or an iCloud.

iOS 15.3.1

Error log after picking a folder "Test" in the internal directory structure:

“Test” couldn’t be moved because you don’t have permission to access “tmp”.
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x1808e10fc 0x199131d64 0x1809ea564 0x1808770e4 0x104dd361c 0x1836ec2dc 0x18309a524 0x1835e2748 0x182f31f18 0x183144998 0x182f9b190 0x182fb5dd0 0x182e812e8 0x182e95a5c 0x182e95bc4 0x18466aa08 0x180553670 0x180561b70 0x180899d84 0x180853f5c 0x180867468 0x19c40b38c 0x18320a5d0 0x182f88f74 0x102efcb28 0x10434daa4)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001b7ecc964 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x1b7ecc964 <+8>:  b.lo   0x1b7ecc984               ; <+40>
    0x1b7ecc968 <+12>: pacibsp 
    0x1b7ecc96c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1b7ecc970 <+20>: mov    x29, sp
Target 0: (Runner) stopped.
Lost connection to device.

Exited.

Why is it even trying to move the "Test" directory? I just picked it as a target to save a file into at a later step, nothing else...

@github-actions github-actions bot removed the stale label Feb 15, 2024
@mrwill84
Copy link

any updated here ? I met same issue :(

@TheRedSpy15
Copy link

very frustrating this issue is seemingly ignored. this library is basically the only way to access files/folders with flutter

@ryanhoo
Copy link

ryanhoo commented Feb 18, 2024

Same here, any solutions? @miguelpruivo

@ElHyperion
Copy link

ElHyperion commented Feb 18, 2024

I tested some older versions of this library and it seems to yield the same issue, perhaps there has been a breaking change in newer iOS versions?

@TheRedSpy15
Copy link

TheRedSpy15 commented Feb 18, 2024

I tested some older versions of this library and it seems to yield the same issue, perhaps there has been a breaking change in newer iOS versions?

I'm trying on ios 16 (physical device) and experiencing it

@logan-oss
Copy link

Same here, we need a fix please.

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 Feb 29, 2024
@mateusz-bak
Copy link

Bump

@github-actions github-actions bot removed the stale label Mar 8, 2024
Copy link

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

@github-actions github-actions bot added the stale label Mar 15, 2024
@mateusz-bak
Copy link

Bumped

@github-actions github-actions bot removed the stale label Mar 16, 2024
@miguelpruivo
Copy link
Owner

What's the status of this? Haven't experienced any issue in the meantime. Does this only happen on iOS 17.0? I'm not sure if I correctly understood the issue, it doesn't pick the path, is that it?

@miguelpruivo miguelpruivo added triage Further information is requested needs investigation iOS Issue applies to iOS platform and removed new issue An issue that hasn't yet been seen from the maintainer labels Mar 20, 2024
@miguelpruivo miguelpruivo self-assigned this Mar 20, 2024
@ElHyperion
Copy link

ElHyperion commented Mar 20, 2024

@miguelpruivo The issue is present on iOS 15 and newer, not Android. Picking any directory results in the missing permissions for "tmp" error message for me (as seen in my error log above), not sure about what others get.

@miguelpruivo
Copy link
Owner

I guess I'll have to try to replicate in order to fix it or some issue a PR.

Any reproducible example or steps to?

@ElHyperion
Copy link

Simply calling FilePicker.platform.getDirectoryPath(); and picking -any- directory, whether internal or on iCloud, was enough for me. The issue happened every time.

@we-prajapati-c001
Copy link

For me on real devices the issue is reproducible. Works fine for simulator.

@miguelpruivo
Copy link
Owner

Simply calling FilePicker.platform.getDirectoryPath(); and picking -any- directory, whether internal or on iCloud, was enough for me. The issue happened every time.

But what is exactly the issue?

@ElHyperion
Copy link

@miguelpruivo selecting the directory crashes the app and throws the error that I pasted above.

@hasanmhallak
Copy link
Author

hasanmhallak commented Mar 20, 2024

hey @miguelpruivo, sorry for the late replay.

When invoking FilePicker.platform.getDirectoryPath(); on Android, it successfully returns the actual path of any selected directory.

However, on iOS, due to the limitations you've outlined in your FAQ, one must copy the file or directory to a temporary directory for access.

An issue arises with FilePicker.platform.getDirectoryPath(); on iOS, where it moves the directory instead of copying it, contrary to the expected behavior. As a result, the user will permanently lose access to that directory.

This concern is addressed in the issue that I've opened.

Edit:

This making me wonder if we was able to move the original folder why we are copying the file in first place?

Copy link

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

@github-actions github-actions bot added the stale label Mar 29, 2024
@mateusz-bak
Copy link

Bump

@github-actions github-actions bot removed the stale label Mar 30, 2024
Copy link

github-actions bot commented Apr 6, 2024

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

@github-actions github-actions bot added the stale label Apr 6, 2024
@mateusz-bak
Copy link

Bump

@github-actions github-actions bot removed the stale label Apr 7, 2024
Copy link

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

@github-actions github-actions bot added the stale label Apr 14, 2024
@mateusz-bak
Copy link

Bump

@github-actions github-actions bot removed the stale label Apr 15, 2024
Copy link

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

@github-actions github-actions bot added the stale label Apr 23, 2024
@we-prajapati-c001
Copy link

bump

@github-actions github-actions bot removed the stale label Apr 24, 2024
Copy link

github-actions bot commented May 8, 2024

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

@github-actions github-actions bot added the stale label May 8, 2024
@we-prajapati-c001
Copy link

bump

@github-actions github-actions bot removed the stale label May 9, 2024
@razumeiko
Copy link

@miguelpruivo
Here is the error

“Test” couldn’t be moved because you don’t have permission to access “tmp”.
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x1a115bf24 0x199012018 0x1a10fd2d8 0x10220f740 0x1a3ca3740 0x1a36157d4 0x1a3615278 0x1a366ec40 0x1a37127f4 0x1a3712478 0x1a33ee56c 0x1a33ee450 0x1a33ed168 0x1a33fa844 0x1a33fa8b4 0x1a27a11ac 0x1036067bc 0x103616d58 0x10361690c 0x1a112e750 0x1a112b954 0x1a112ad18 0x1e5c9e1a8 0x1a3767058 0x1a381b04c 0x10211c798 0x1c4b6fe4c)
libc++abi: terminating due to uncaught exception of type NSException

I think problem is that it's trying to move the directory, I did not find a way to add permissions to tmp, everything points that it's already should be granted.

@julian-CStack
Copy link

@miguelpruivo Here is the error

“Test” couldn’t be moved because you don’t have permission to access “tmp”.
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x1a115bf24 0x199012018 0x1a10fd2d8 0x10220f740 0x1a3ca3740 0x1a36157d4 0x1a3615278 0x1a366ec40 0x1a37127f4 0x1a3712478 0x1a33ee56c 0x1a33ee450 0x1a33ed168 0x1a33fa844 0x1a33fa8b4 0x1a27a11ac 0x1036067bc 0x103616d58 0x10361690c 0x1a112e750 0x1a112b954 0x1a112ad18 0x1e5c9e1a8 0x1a3767058 0x1a381b04c 0x10211c798 0x1c4b6fe4c)
libc++abi: terminating due to uncaught exception of type NSException

I think problem is that it's trying to move the directory, I did not find a way to add permissions to tmp, everything points that it's already should be granted.

Also experiencing this

Copy link

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

@github-actions github-actions bot added the stale label May 21, 2024
@we-prajapati-c001
Copy link

bump

@github-actions github-actions bot removed the stale label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS Issue applies to iOS platform needs investigation triage Further information is requested
Projects
None yet
Development

No branches or pull requests