浏览代码

Merge pull request #7230 from nextcloud/fixNullOnAutoUpload

If relative subfolder cannot be found, do not use it
Andy Scherzinger 4 年之前
父节点
当前提交
3db917addb
共有 1 个文件被更改,包括 8 次插入2 次删除
  1. 8 2
      src/main/java/com/owncloud/android/utils/FileStorageUtils.java

+ 8 - 2
src/main/java/com/owncloud/android/utils/FileStorageUtils.java

@@ -175,8 +175,14 @@ public final class FileStorageUtils {
             subfolderByDatePath = getSubPathFromDate(dateTaken, current);
             subfolderByDatePath = getSubPathFromDate(dateTaken, current);
         }
         }
 
 
-        String relativeSubfolderPath = new File(file.getAbsolutePath().replace(syncedFolderLocalPath, ""))
-            .getParentFile().getAbsolutePath();
+        File parentFile = new File(file.getAbsolutePath().replace(syncedFolderLocalPath, "")).getParentFile();
+
+        String relativeSubfolderPath = "";
+        if (parentFile == null) {
+            Log_OC.e("AutoUpload", "Parent folder does not exists!");
+        } else {
+            relativeSubfolderPath = parentFile.getAbsolutePath();
+        }
 
 
         // Path must be normalized; otherwise the next RefreshFolderOperation has a mismatch and deletes the local file.
         // Path must be normalized; otherwise the next RefreshFolderOperation has a mismatch and deletes the local file.
         return (remotePath +
         return (remotePath +