ionic-team / ionic-team/capacitor-filesystem
Multiple calls triggering request for filesystem user permission get wrong results
- Dominant language
- TypeScript
- Stars
- 6
- Forks
- 15
- Avg merge
- 14m
- Merged PRs (30d)
- 1
Description
Description of the problem:
When the user tries to access the Filesystem without having the permission, the user gets prompted to grant such permission. If in the meantime another request is made, after the user grants the permission the result of the first call is returned to the second request.
More in detail there’s no way to have two calls in progress at the same time,
so `mkdir` will call `requestPermissions()` and set `savedLastCall`
`stat` will also call `requestPermissions()` and overwrite `savedLastCall`
Affected platform
- [X] Android
- [ ] iOS
- [ ] electron
- [ ] web
OS of the development machine
- [ ] Windows
- [X] macOS
- [ ] linux
Capacitor version:
Master at sha
https://github.com/ionic-team/capacitor/tree/519b9b3d5abacaa232af810fa9dbc952cdec693b
Steps to reproduce:
In the browser console for the example app type:
```
Capacitor.Plugins.Filesystem.mkdir({path: 'foooooooo', directory: 'DOCUMENTS'}).then(console.log, console.error)
```
Then, without granting the permission on the app, type:
```
Capacitor.Plugins.Filesystem.stat({path: 'foooooooo', directory: 'DOCUMENTS'}).then(console.log, console.error)
```
Then grant the filesystem permission on the app and you will get the result of the first call `mkdir` to the `stat` call.
Contributor guide
Assessment
This issue has not been assessed yet.