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

Fix issue where invoke would be called more than once during cp call #408

Merged
merged 1 commit into from
Jun 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ static void cp(String path, String dest, Callback callback) {
path = normalizePath(path);
InputStream in = null;
OutputStream out = null;
String message = "";

try {

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

} catch (Exception err) {
callback.invoke(err.getLocalizedMessage());
message += err.getLocalizedMessage();
} finally {
try {
if (in != null) {
Expand All @@ -473,11 +474,16 @@ static void cp(String path, String dest, Callback callback) {
if (out != null) {
out.close();
}
callback.invoke();
} catch (Exception e) {
callback.invoke(e.getLocalizedMessage());
message += e.getLocalizedMessage();
}
}

if (message != "") {
callback.invoke(message);
} else {
callback.invoke();
}
}

/**
Expand Down