ionic-team / ionic-team/capacitor-filesystem
Filesystem.readdir returns platform-dependent order between iOS and Android
- Dominant language
- TypeScript
- Stars
- 6
- Forks
- 15
- Avg merge
- 14m
- Merged PRs (30d)
- 1
Description
## Bug Report
### Plugin
`@capacitor/filesystem`
### Current behavior
`Filesystem.readdir()` does not guarantee a deterministic order across platforms. In practice, iOS and Android can return entries in different orders for the same logical dataset.
For offline-first apps, this can lead to subtle cross-platform bugs when application code assumes chronological ordering (for sync queues, local media timelines, pending uploads, etc.).
### Real-world scenario
A mobile app available on both iOS and Android stores files locally while offline (e.g. photos, notes, or sync payloads). Files are written in chronological order and then listed with `readdir()` to process oldest-first.
Even when the storage/write behavior is chronologically identical on both platforms, `readdir()` may return a different order, causing:
- different processing order between platforms,
- inconsistent UI ordering,
- duplicate/conflicting sync behavior in edge cases.
### Expected behavior
`Filesystem.readdir()` should return entries in a deterministic, cross-platform order (for example by `mtime`, then `ctime`, then `name` as stable tie-breaker), or explicitly document and expose sorting controls.
### Reproduction idea
1. Create multiple files in quick succession in the same directory on iOS and Android.
2. Call `Filesystem.readdir()` for that directory.
3. Compare returned arrays between platforms.
4. Observe order differences despite equivalent file creation behavior.
### Why this matters
Offline-first applications commonly rely on deterministic local ordering to avoid cross-platform divergence. Platform-dependent directory iteration order can cause hard-to-debug functional regressions.
Contributor guide
Assessment
This issue has not been assessed yet.