瀏覽代碼

Retrieve parent folder before removing document

Otherwise trying to get the parent folder will cause a NPE

Fixes #5015

Signed-off-by: Torsten Grote <t@grobox.de>
Torsten Grote 5 年之前
父節點
當前提交
d82de88701
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java

+ 2 - 2
src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java

@@ -573,6 +573,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
         }
         }
 
 
         Document document = toDocument(documentId);
         Document document = toDocument(documentId);
+        // get parent here, because it is not available anymore after the document was deleted
+        Document parentFolder = document.getParent();
 
 
         recursiveRevokePermission(document);
         recursiveRevokePermission(document);
 
 
@@ -583,8 +585,6 @@ public class DocumentsStorageProvider extends DocumentsProvider {
         if (!result.isSuccess()) {
         if (!result.isSuccess()) {
             throw new FileNotFoundException("Failed to delete document with documentId " + documentId);
             throw new FileNotFoundException("Failed to delete document with documentId " + documentId);
         }
         }
-
-        Document parentFolder = document.getParent();
         context.getContentResolver().notifyChange(toNotifyUri(parentFolder), null, false);
         context.getContentResolver().notifyChange(toNotifyUri(parentFolder), null, false);
     }
     }