diff options
author | Robin Appelman <robin@icewind.nl> | 2019-02-27 15:35:44 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2019-02-27 15:35:44 +0100 |
commit | 8fc47c6f002dd47518cea34ec5fe113fa5b915b7 (patch) | |
tree | d414e72b5285a342b000f1f514d73e37964034cc /lib/private/Files/FileInfo.php | |
parent | 407c7c2ad356baf83cadbc5edb9db49146766650 (diff) | |
download | nextcloud-server-8fc47c6f002dd47518cea34ec5fe113fa5b915b7.tar.gz nextcloud-server-8fc47c6f002dd47518cea34ec5fe113fa5b915b7.zip |
add option to get raw size (without submounts) from fileinfo
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/FileInfo.php')
-rw-r--r-- | lib/private/Files/FileInfo.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/private/Files/FileInfo.php b/lib/private/Files/FileInfo.php index 575af56ceb5..19b95cd0355 100644 --- a/lib/private/Files/FileInfo.php +++ b/lib/private/Files/FileInfo.php @@ -81,6 +81,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 * @param string $internalPath @@ -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; + } } /** |