add option to get raw size (without submounts) from fileinfo

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/14412/head
Robin Appelman 7 years ago
parent 407c7c2ad3
commit 8fc47c6f00
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
  1. 6
      apps/files_trashbin/lib/Trash/TrashItem.php
  2. 18
      lib/private/Files/FileInfo.php
  3. 2
      lib/private/Files/Node/LazyRoot.php
  4. 5
      lib/private/Files/Node/Node.php
  5. 4
      lib/private/Files/Node/NonExistingFile.php
  6. 4
      lib/private/Files/Node/NonExistingFolder.php
  7. 3
      lib/private/Files/Node/Root.php
  8. 3
      lib/public/Files/FileInfo.php
  9. 3
      lib/public/Files/Node.php

@ -82,8 +82,8 @@ class TrashItem implements ITrashItem {
return $this->fileInfo->getEtag();
}
public function getSize() {
return $this->fileInfo->getSize();
public function getSize($includeMounts = true) {
return $this->fileInfo->getSize($includeMounts);
}
public function getMtime() {
@ -133,7 +133,7 @@ class TrashItem implements ITrashItem {
public function isReadable() {
return $this->fileInfo->isReadable();
}
public function isUpdateable() {
return $this->fileInfo->isUpdateable();
}

@ -80,6 +80,13 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
private $subMountsUsed = false;
/**
* The size of the file/folder without any sub mount
*
* @var int
*/
private $rawSize = 0;
/**
* @param string|boolean $path
* @param Storage\Storage $storage
@ -95,6 +102,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
$this->data = $data;
$this->mount = $mount;
$this->owner = $owner;
$this->rawSize = $this->data['size'] ?? 0;
}
public function offsetSet($offset, $value) {
@ -194,9 +202,13 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
/**
* @return int
*/
public function getSize() {
$this->updateEntryfromSubMounts();
return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
public function getSize($includeMounts = true) {
if ($includeMounts) {
$this->updateEntryfromSubMounts();
return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
} else {
return $this->rawSize;
}
}
/**

@ -214,7 +214,7 @@ class LazyRoot implements IRootFolder {
/**
* @inheritDoc
*/
public function getSize() {
public function getSize($includeMounts = true) {
return $this->__call(__FUNCTION__, func_get_args());
}

@ -190,12 +190,13 @@ class Node implements \OCP\Files\Node {
}
/**
* @param bool $includeMounts
* @return int
* @throws InvalidPathException
* @throws NotFoundException
*/
public function getSize() {
return $this->getFileInfo()->getSize();
public function getSize($includeMounts = true) {
return $this->getFileInfo()->getSize($includeMounts);
}
/**

@ -66,9 +66,9 @@ class NonExistingFile extends File {
}
}
public function getSize() {
public function getSize($includeMounts = true) {
if ($this->fileInfo) {
return parent::getSize();
return parent::getSize($includeMounts);
} else {
throw new NotFoundException();
}

@ -67,9 +67,9 @@ class NonExistingFolder extends Folder {
}
}
public function getSize() {
public function getSize($includeMounts = true) {
if ($this->fileInfo) {
return parent::getSize();
return parent::getSize($includeMounts);
} else {
throw new NotFoundException();
}

@ -282,9 +282,10 @@ class Root extends Folder implements IRootFolder {
}
/**
* @param bool $includeMounts
* @return int
*/
public function getSize() {
public function getSize($includeMounts = true) {
return null;
}

@ -81,10 +81,11 @@ interface FileInfo {
/**
* Get the size in bytes for the file or folder
*
* @param bool $includeMounts whether or not to include the size of any sub mounts, since 16.0.0
* @return int
* @since 7.0.0
*/
public function getSize();
public function getSize($includeMounts = true);
/**
* Get the last modified date as timestamp for the file or folder

@ -136,12 +136,13 @@ interface Node extends FileInfo {
/**
* Get the size of the file or folder in bytes
*
* @param bool $includeMounts
* @return int
* @throws InvalidPathException
* @throws NotFoundException
* @since 6.0.0
*/
public function getSize();
public function getSize($includeMounts = true);
/**
* Get the Etag of the file or folder

Loading…
Cancel
Save