You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error: Failed to create parent directory of '/data/user/0/tuerantuer.app.integreat/files/content/v1/lkvechta/bg/pois.json'
possible explanation
While I was not able to reproduce the error myself, we got some reports via sentry about this issue. It seems like this happens sometimes because of a race condition (e.g. with redux-saga) if attempting to create two files in the same not yet existing directory. Possible execution order:
First call to writeFile gets result that parent directory does not exist
Second call to writeFile gets result that parent directory does not exist
First call to writeFile creates parent directory
Second call to writeFile tries to create parent directory but gets result false from Java.io.File.mkdirs() since parent directory does already exist
Second call to writeFile throws Failed to create parent directory exception
proposed solution
Only throw an exception if the parent directory does still not exist after attempting to create parent directory, i.e. replace
if (!dir.mkdirs()) {
promise.reject("ENOTDIR", "Failed to create parent directory of '" + path + "'");
return;
}
with
if (!dir.mkdirs() && !dir.exists()) {
promise.reject("ENOTDIR", "Failed to create parent directory of '" + path + "'");
return;
}
environment
react-native-blob-util version: 0.13.6
react-native: 0.66.1
code (simplified)
error
possible explanation
While I was not able to reproduce the error myself, we got some reports via sentry about this issue. It seems like this happens sometimes because of a race condition (e.g. with redux-saga) if attempting to create two files in the same not yet existing directory. Possible execution order:
writeFile
gets result that parent directory does not existwriteFile
gets result that parent directory does not existwriteFile
creates parent directorywriteFile
tries to create parent directory but gets resultfalse
from Java.io.File.mkdirs() since parent directory does already existwriteFile
throwsFailed to create parent directory
exceptionproposed solution
Only throw an exception if the parent directory does still not exist after attempting to create parent directory, i.e. replace
with
Corresponding lines: https://github.com/joltup/rn-fetch-blob/blob/dcbde6f7e12b666b9fe1c8c4a8e2cb04e0048326/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java#L61
Created a PR for this: #85
Thanks for maintaining this project btw 🙏
The text was updated successfully, but these errors were encountered: