Skip to content

Commit ef554fb

Browse files
authored
Merge pull request #85 from klinzo/15-check-dir-existing-before-throwing
Only throw error if dir does not exist after attempting to create
2 parents 03aec72 + 96ca80b commit ef554fb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void writeFile(String path, String encoding, String data, final boolean a
5757

5858
if (!f.exists()) {
5959
if (dir != null && !dir.exists()) {
60-
if (!dir.mkdirs()) {
60+
if (!dir.mkdirs() && !dir.exists()) {
6161
promise.reject("EUNSPECIFIED", "Failed to create parent directory of '" + path + "'");
6262
return;
6363
}
@@ -129,7 +129,7 @@ static void writeFile(String path, ReadableArray data, final boolean append, fin
129129

130130
if (!f.exists()) {
131131
if (dir != null && !dir.exists()) {
132-
if (!dir.mkdirs()) {
132+
if (!dir.mkdirs() && !dir.exists()) {
133133
promise.reject("ENOTDIR", "Failed to create parent directory of '" + path + "'");
134134
return;
135135
}
@@ -445,7 +445,7 @@ void writeStream(String path, String encoding, boolean append, Callback callback
445445

446446
if (!dest.exists()) {
447447
if (dir != null && !dir.exists()) {
448-
if (!dir.mkdirs()) {
448+
if (!dir.mkdirs() && !dir.exists()) {
449449
callback.invoke("ENOTDIR", "Failed to create parent directory of '" + path + "'");
450450
return;
451451
}

0 commit comments

Comments
 (0)