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

Commit

Permalink
Add exception handling when file does not removed correctly #236
Browse files Browse the repository at this point in the history
  • Loading branch information
wkh237 committed Apr 15, 2017
1 parent 90767ff commit 89d1f68
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,16 @@ static void unlink(String path, Callback callback) {
}
}

static void deleteRecursive(File fileOrDirectory) {
static void deleteRecursive(File fileOrDirectory) throws Exception {

if (fileOrDirectory.isDirectory()) {
for (File child : fileOrDirectory.listFiles()) {
deleteRecursive(child);
}
}
fileOrDirectory.delete();
boolean removed = fileOrDirectory.delete();
if(!removed)
throw new Exception("file at path " + fileOrDirectory.getAbsolutePath() + " could not be removed.");
}

/**
Expand Down

0 comments on commit 89d1f68

Please sign in to comment.