itinance / itinance/react-native-fs
RNFS.exists() returns false but RNFS.writeFile() gives ENOENT: open failed: EEXIST (File exists)
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
This only happens on some specific devices. Vanilla Android seems to work fine but I have seen this issue on OnePlus and Samsung devices. The user downloads a file and deletes it using the file manager, then tries to download it again.
The gist of the code is this:
```javascript
const ext = "pdf";
let uniquePath = `${RNFS.DownloadDirectoryPath}/myFile`;
while(await RNFS.exists(${uniquePath}.${ext}`)) {
uniquePath = `${uniquePath} (${n++})`;
}
const filePath = `${uniquePath}.${ext}`;
// Log for sanity
console.log("File exists?", await RNFS.exists(filePath)); // This line logs 'File exists? false'
await RNFS.writeFile(filePath, contents, 'base64'); // Throws exception ENOENT: open failed: EEXIST (File exists)
```
The main device I am seeing this on is a OnePlus 7 Pro running Android 11.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.