Revert "reduce contentresolver/sql queries"

This reverts commit ec5a73142dee30cd909db9e68b97ef65456f7c48.

Signed-off-by: Jens Mueller <tschenser@gmx.de>
This commit is contained in:
Jens Mueller 2019-08-06 21:42:29 +02:00 committed by Andy Scherzinger
parent 5de451fa98
commit 8d24d80fdc
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -395,7 +395,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
}
Document newFile = new Document(storageManager, newPath);
context.getContentResolver().notifyChange(toNotifyUri(targetFolder), null, false);
context.getContentResolver().notifyChange(toNotifyUri(newFile.getParent()), null, false);
return newFile.getDocumentId();
}
@ -754,27 +754,27 @@ public class DocumentsStorageProvider extends DocumentsProvider {
public class Document {
private final FileDataStorageManager storageManager;
private final OCFile file;
private final long fileId;
Document(FileDataStorageManager storageManager, long fileId) {
this.storageManager = storageManager;
this.file = storageManager.getFileById(fileId);
this.fileId = fileId;
}
Document(FileDataStorageManager storageManager, OCFile file) {
this.storageManager = storageManager;
this.file = file;
this.fileId = file.getFileId();
}
Document(FileDataStorageManager storageManager, String filePath) {
this.storageManager = storageManager;
this.file = storageManager.getFileByPath(filePath);
this.fileId = storageManager.getFileByPath(filePath).getFileId();
}
public String getDocumentId() {
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
if (Objects.equals(storageManager, rootIdToStorageManager.valueAt(i))) {
return rootIdToStorageManager.keyAt(i) + DOCUMENTID_SEPARATOR + file.getFileId();
return rootIdToStorageManager.keyAt(i) + DOCUMENTID_SEPARATOR + fileId;
}
}
return null;
@ -789,7 +789,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
}
public OCFile getFile() {
return file;
return getStorageManager().getFileById(fileId);
}
public String getRemotePath() {
@ -812,7 +812,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
}
Document getParent() {
long parentId = file.getParentId();
long parentId = getFile().getParentId();
if (parentId <= 0) {
return null;
}