Skip to content

Commit

Permalink
fix: make sure unlink throws if somehow it couldnt
Browse files Browse the repository at this point in the history
  • Loading branch information
jd1378 committed Aug 29, 2022
1 parent cec8907 commit c0a7887
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion android/src/main/java/com/reactnativesafx/SafXModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ public void unlink(String uriString, final Promise promise) {
try {
DocumentFile doc = this.documentHelper.goToDocument(uriString, false, true);
boolean result = doc.delete();
promise.resolve(result);
if (!result) {
throw new Exception("Failed to unlink file. Unknown error.");
}
promise.resolve(true);
} catch (FileNotFoundException e) {
promise.resolve(true);
} catch (SecurityException e) {
Expand Down

0 comments on commit c0a7887

Please sign in to comment.