]> source.dussan.org Git - nextcloud-server.git/commitdiff
allow setting some metadata in the lazyfolder without having to get the real folder
authorRobin Appelman <robin@icewind.nl>
Tue, 8 Mar 2022 15:18:43 +0000 (16:18 +0100)
committerRobin Appelman <robin@icewind.nl>
Thu, 24 Mar 2022 16:01:01 +0000 (17:01 +0100)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/Node/LazyFolder.php

index bfdaeeccff7e115471051d4c6283bb25cd20ae0c..45451e5c53ce85faf02c564fade4545ac75adb6b 100644 (file)
@@ -25,6 +25,8 @@ declare(strict_types=1);
  */
 namespace OC\Files\Node;
 
+use OCP\Constants;
+
 /**
  * Class LazyFolder
  *
@@ -40,13 +42,16 @@ class LazyFolder implements \OCP\Files\Folder {
        /** @var LazyFolder | null */
        protected $folder = null;
 
+       protected array $data;
+
        /**
         * LazyFolder constructor.
         *
         * @param \Closure $folderClosure
         */
-       public function __construct(\Closure $folderClosure) {
+       public function __construct(\Closure $folderClosure, array $data = []) {
                $this->folderClosure = $folderClosure;
+               $this->data = $data;
        }
 
        /**
@@ -181,6 +186,9 @@ class LazyFolder implements \OCP\Files\Folder {
         * @inheritDoc
         */
        public function getPath() {
+               if (isset($this->data['path'])) {
+                       return $this->data['path'];
+               }
                return $this->__call(__FUNCTION__, func_get_args());
        }
 
@@ -230,6 +238,9 @@ class LazyFolder implements \OCP\Files\Folder {
         * @inheritDoc
         */
        public function getPermissions() {
+               if (isset($this->data['permissions'])) {
+                       return $this->data['permissions'];
+               }
                return $this->__call(__FUNCTION__, func_get_args());
        }
 
@@ -237,6 +248,9 @@ class LazyFolder implements \OCP\Files\Folder {
         * @inheritDoc
         */
        public function isReadable() {
+               if (isset($this->data['permissions'])) {
+                       return ($this->data['permissions'] & Constants::PERMISSION_READ) == Constants::PERMISSION_READ;
+               }
                return $this->__call(__FUNCTION__, func_get_args());
        }
 
@@ -244,6 +258,9 @@ class LazyFolder implements \OCP\Files\Folder {
         * @inheritDoc
         */
        public function isUpdateable() {
+               if (isset($this->data['permissions'])) {
+                       return ($this->data['permissions'] & Constants::PERMISSION_UPDATE) == Constants::PERMISSION_UPDATE;
+               }
                return $this->__call(__FUNCTION__, func_get_args());
        }
 
@@ -251,6 +268,9 @@ class LazyFolder implements \OCP\Files\Folder {
         * @inheritDoc
         */
        public function isDeletable() {
+               if (isset($this->data['permissions'])) {
+                       return ($this->data['permissions'] & Constants::PERMISSION_DELETE) == Constants::PERMISSION_DELETE;
+               }
                return $this->__call(__FUNCTION__, func_get_args());
        }
 
@@ -258,6 +278,9 @@ class LazyFolder implements \OCP\Files\Folder {
         * @inheritDoc
         */
        public function isShareable() {
+               if (isset($this->data['permissions'])) {
+                       return ($this->data['permissions'] & Constants::PERMISSION_SHARE) == Constants::PERMISSION_SHARE;
+               }
                return $this->__call(__FUNCTION__, func_get_args());
        }