itinance / itinance/react-native-fs

ENOENT: open failed: ENOENT (no such file or directory) XIAOMI only?

Open
#1,017 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Hello all.
I'm using RNFS to store imagens took with my app, wich its sent later to an API.
The follow code, is in my app used by +- 100 users. **But only 2 of them** (wich both have XIAOMI phones, with android 10) is having this ENOENT error.

```
async takePhoto() {
const hasPermissions = await Util.checkPermissions();
if (hasPermissions) {
launchCamera(this.PHOTO_OPTIONS, (response) => {
if (response.didCancel) {
return;
}
if (response.error) {
Alert.alert('ImagePicker error: ', `${response.error}`, [
{ text: 'OK', onPress: () => { } },
]);
}

this.setState({ loading: true })

const AppFolder = 'myapp/Images';
const DirectoryPath= RNFS.DownloadDirectoryPath +'/../'+ AppFolder;
RNFS.mkdir(DirectoryPath);

const destPath = `${DirectoryPath}/${response.fileName}`

RNFS.moveFile(response.uri, destPath)
.then((success) => {
Geolocation.getCurrentPosition(position => {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;

if (!!this.state.images[this.state.imageIndex]) {
const imgs = this.state.images;
RNFS.unlink(imgs[this.state.imageIndex]);
imgs[this.state.imageIndex] = destPath;

this.setState({ images: imgs, imageIndex: null, loading: false })
} else {
this.setState({
images: [...this.state.images, destPath], latitudes: [...this.state.latitudes, latitude],
longitudes: [...this.state.longitudes, longitude], loading: false
});
}
}, error => {
this.showGpsError();

const code = error.code;
const msg = error.message;

if (!!this.state.images[this.state.imageIndex]) {
const imgs = this.state.images;
RNFS.unlink(imgs[this.state.imageIndex]);
imgs[this.state.imageIndex] = destPath;

this.setState({ images: imgs, imageIndex: null, loading: false })
} else {
this.setState({
images: [...this.state.images, destPath], errorCode: code, errorMsg: msg,
loading: false
});
}
},
this.GPS_OPTIONS
);
})
.catch((err) => {
Alert.alert('RNFS error: ', `${err.message}`, [
{ text: 'OK', onPress: () => { } },
]);
})
})
}
}
```

PS: I'm checking (and requesting) permissions to WRITE_EXTERNAL_STORAGE and ACCESS_FINE_LOCATION.

There is something wrong with my code, or using RNFS? I check it a few times, and couldnt understand whats happening in this devices.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.