mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 14:15:44 +03:00
fix isChildDocument()
Signed-off-by: Jens Mueller <tschenser@gmx.de>
This commit is contained in:
parent
b2eacc46b4
commit
a2350598da
1 changed files with 13 additions and 6 deletions
|
@ -616,14 +616,16 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
|||
Log.d(TAG, "isChildDocument(), parent=" + parentDocumentId + ", id=" + documentId);
|
||||
|
||||
try {
|
||||
Document document = toDocument(documentId);
|
||||
Document folderDocument = toDocument(parentDocumentId);
|
||||
Document currentDocument = toDocument(documentId);
|
||||
Document parentDocument = toDocument(parentDocumentId);
|
||||
|
||||
if (null == document || null == folderDocument) {
|
||||
return false;
|
||||
while (!ROOT_PATH.equals(currentDocument.getRemotePath())) {
|
||||
currentDocument = currentDocument.getParent();
|
||||
if (parentDocument.getFile().equals(currentDocument.getFile())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return document.getFile().getParentId() == folderDocument.getFile().getFileId();
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.e(TAG, "failed to check for child document", e);
|
||||
}
|
||||
|
@ -802,7 +804,12 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
|||
}
|
||||
|
||||
Document getParent() {
|
||||
return new Document(getStorageManager(), getFile().getParentId());
|
||||
long parentId = getFile().getParentId();
|
||||
if (parentId <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Document(getStorageManager(), parentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue