From cfd3aab9528acb7040c6c86e32e9f8f52fb28d08 Mon Sep 17 00:00:00 2001 From: Jens Mueller Date: Thu, 1 Aug 2019 18:00:21 +0200 Subject: [PATCH] reduce contentresolver/sql queries Signed-off-by: Jens Mueller --- .../providers/DocumentsStorageProvider.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java b/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java index cd18dac8ca..64b01fead0 100644 --- a/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java +++ b/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java @@ -387,7 +387,7 @@ public class DocumentsStorageProvider extends DocumentsProvider { } Document newFile = new Document(storageManager, newPath); - context.getContentResolver().notifyChange(toNotifyUri(newFile.getParent()), null, false); + context.getContentResolver().notifyChange(toNotifyUri(targetFolder), null, false); return newFile.getDocumentId(); } @@ -746,27 +746,27 @@ public class DocumentsStorageProvider extends DocumentsProvider { public class Document { private final FileDataStorageManager storageManager; - private final long fileId; + private final OCFile file; Document(FileDataStorageManager storageManager, long fileId) { this.storageManager = storageManager; - this.fileId = fileId; + this.file = storageManager.getFileById(fileId); } Document(FileDataStorageManager storageManager, OCFile file) { this.storageManager = storageManager; - this.fileId = file.getFileId(); + this.file = file; } Document(FileDataStorageManager storageManager, String filePath) { this.storageManager = storageManager; - this.fileId = storageManager.getFileByPath(filePath).getFileId(); + this.file = storageManager.getFileByPath(filePath); } public String getDocumentId() { for(int i = 0; i < rootIdToStorageManager.size(); i++) { if (Objects.equals(storageManager, rootIdToStorageManager.valueAt(i))) { - return rootIdToStorageManager.keyAt(i) + DOCUMENTID_SEPARATOR + fileId; + return rootIdToStorageManager.keyAt(i) + DOCUMENTID_SEPARATOR + file.getFileId(); } } return null; @@ -781,7 +781,7 @@ public class DocumentsStorageProvider extends DocumentsProvider { } public OCFile getFile() { - return getStorageManager().getFileById(fileId); + return file; } public String getRemotePath() { @@ -804,7 +804,7 @@ public class DocumentsStorageProvider extends DocumentsProvider { } Document getParent() { - long parentId = getFile().getParentId(); + long parentId = file.getParentId(); if (parentId <= 0) { return null; }