瀏覽代碼

Added check for failing to create the output directory

adamburnett 5 年之前
父節點
當前提交
480093530c
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6
    2
      android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java

+ 6
- 2
android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java 查看文件

@@ -604,7 +604,11 @@ class RNFetchBlobFS {
604 604
         File dir = new File(dest);
605 605
         if (!dir.exists())
606 606
         {
607
-            dir.mkdirs();
607
+            if (!dir.mkdirs())
608
+            {
609
+                callback.invoke("Output directory creation failed.");
610
+                return;
611
+            }
608 612
         }
609 613
 
610 614
         try {
@@ -622,7 +626,7 @@ class RNFetchBlobFS {
622 626
 
623 627
             src.delete(); //remove original file
624 628
         } catch (FileNotFoundException exception) {
625
-            callback.invoke(exception.toString());
629
+            callback.invoke("Source file not found.");
626 630
             return;
627 631
         } catch (Exception e) {
628 632
             callback.invoke(e.toString());