diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-10-29 16:56:06 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-10-30 09:45:27 +0100 |
commit | 8085ca4cc4e0d38e33b623613b36ec0fe03e5a9f (patch) | |
tree | 8fdb99486678156da016425e36d8444bdfe34821 /lib/public | |
parent | 380563fd53a2f03d772614388a9f345579ba7ca3 (diff) | |
download | nextcloud-server-8085ca4cc4e0d38e33b623613b36ec0fe03e5a9f.tar.gz nextcloud-server-8085ca4cc4e0d38e33b623613b36ec0fe03e5a9f.zip |
Get all shares as iterable
Sometimes we need all shares or rather a specific subset of shares but
creating dedicated functions is a pain. This just returns an iterable
object for all shares so we can loop over them without allocating all
the memory on the system.
It should not be used by any user called code. But in an occ command or
background job it is fine IMO.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/Share/IManager.php | 11 | ||||
-rw-r--r-- | lib/public/Share/IShareProvider.php | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 302be523327..0c47eb730fd 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -385,4 +385,15 @@ interface IManager { */ public function shareProviderExists($shareType); + /** + * @Internal + * + * Get all the shares as iterable to reduce memory overhead + * Note, since this opens up database cursors the iterable should + * be fully itterated. + * + * @return iterable + */ + public function getAllShares(): iterable; + } diff --git a/lib/public/Share/IShareProvider.php b/lib/public/Share/IShareProvider.php index 6731bf8882b..da29a7b98aa 100644 --- a/lib/public/Share/IShareProvider.php +++ b/lib/public/Share/IShareProvider.php @@ -217,4 +217,12 @@ interface IShareProvider { * @since 12 */ public function getAccessList($nodes, $currentAccess); + + /** + * Get all the shares in this provider returned as iterable to reduce memory + * overhead + * + * @return iterable + */ + public function getAllShares(): iterable; } |