mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
add IFileInfo::getParentId
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
e718cbc661
commit
9055fef5ef
5 changed files with 32 additions and 7 deletions
|
|
@ -186,4 +186,8 @@ class TrashItem implements ITrashItem {
|
|||
public function getUploadTime(): int {
|
||||
return $this->fileInfo->getUploadTime();
|
||||
}
|
||||
|
||||
public function getParentId(): int {
|
||||
return $this->fileInfo->getParentId();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -412,4 +412,8 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
|
|||
public function getUploadTime(): int {
|
||||
return (int) $this->data['upload_time'];
|
||||
}
|
||||
|
||||
public function getParentId(): int {
|
||||
return $this->data['parent'] ?? -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -551,4 +551,11 @@ class LazyFolder implements Folder {
|
|||
public function getRelativePath($path) {
|
||||
return PathHelper::getRelativePath($this->getPath(), $path);
|
||||
}
|
||||
|
||||
public function getParentId(): int {
|
||||
if (isset($this->data['parent'])) {
|
||||
return $this->data['parent'];
|
||||
}
|
||||
return $this->__call(__FUNCTION__, func_get_args());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,10 +59,7 @@ class Node implements INode {
|
|||
|
||||
protected ?FileInfo $fileInfo;
|
||||
|
||||
/**
|
||||
* @var Node|null
|
||||
*/
|
||||
protected $parent;
|
||||
protected ?INode $parent;
|
||||
|
||||
private bool $infoHasSubMountsIncluded;
|
||||
|
||||
|
|
@ -300,13 +297,13 @@ class Node implements INode {
|
|||
return $this->root;
|
||||
}
|
||||
|
||||
// gather the metadata we already know about our parent
|
||||
$parentData = [
|
||||
'path' => $newPath,
|
||||
'fileid' => $this->getFileInfo()->getParentId(),
|
||||
];
|
||||
if ($this->fileInfo instanceof \OC\Files\FileInfo && isset($this->fileInfo['parent'])) {
|
||||
$parentData['fileid'] = $this->fileInfo['parent'];
|
||||
}
|
||||
|
||||
// and create lazy folder with it instead of always querying
|
||||
$this->parent = new LazyFolder(function () use ($newPath) {
|
||||
return $this->root->get($newPath);
|
||||
}, $parentData);
|
||||
|
|
@ -486,4 +483,8 @@ class Node implements INode {
|
|||
public function getUploadTime(): int {
|
||||
return $this->getFileInfo()->getUploadTime();
|
||||
}
|
||||
|
||||
public function getParentId(): int {
|
||||
return $this->fileInfo->getParentId();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,4 +299,13 @@ interface FileInfo {
|
|||
* @since 18.0.0
|
||||
*/
|
||||
public function getUploadTime(): int;
|
||||
|
||||
/**
|
||||
* Get the fileid or the parent folder
|
||||
* or -1 if this item has no parent folder (because it is the root)
|
||||
*
|
||||
* @return int
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function getParentId(): int;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue