add IFileInfo::getParentId

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/38150/head
Robin Appelman 2 years ago
parent e718cbc661
commit 9055fef5ef
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
  1. 4
      apps/files_trashbin/lib/Trash/TrashItem.php
  2. 4
      lib/private/Files/FileInfo.php
  3. 7
      lib/private/Files/Node/LazyFolder.php
  4. 15
      lib/private/Files/Node/Node.php
  5. 9
      lib/public/Files/FileInfo.php

@ -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…
Cancel
Save