Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 6782949

Browse files
maxpowawkh237
authored andcommitted
Fix issue where invoke would be called more than once during cp call (#408)
1 parent 11ef2ea commit 6782949

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ static void cp(String path, String dest, Callback callback) {
444444
path = normalizePath(path);
445445
InputStream in = null;
446446
OutputStream out = null;
447+
String message = "";
447448

448449
try {
449450

@@ -464,7 +465,7 @@ static void cp(String path, String dest, Callback callback) {
464465
}
465466

466467
} catch (Exception err) {
467-
callback.invoke(err.getLocalizedMessage());
468+
message += err.getLocalizedMessage();
468469
} finally {
469470
try {
470471
if (in != null) {
@@ -473,11 +474,16 @@ static void cp(String path, String dest, Callback callback) {
473474
if (out != null) {
474475
out.close();
475476
}
476-
callback.invoke();
477477
} catch (Exception e) {
478-
callback.invoke(e.getLocalizedMessage());
478+
message += e.getLocalizedMessage();
479479
}
480480
}
481+
482+
if (message != "") {
483+
callback.invoke(message);
484+
} else {
485+
callback.invoke();
486+
}
481487
}
482488

483489
/**

0 commit comments

Comments
 (0)