Skip to content

Conversation

@Altahrim
Copy link
Collaborator

Summary

Add an iterator to list files from a directory

Reduce memory usage on large directory listing (≈ 800 files here):
image

Also helps to remove large number of files with Primary object store

Checklist

@Altahrim Altahrim added this to the Nextcloud 34 milestone Jan 29, 2026
@Altahrim Altahrim self-assigned this Jan 29, 2026
@github-project-automation github-project-automation bot moved this to 🏗️ In progress in 📁 Files team Jan 29, 2026
@Altahrim Altahrim force-pushed the feat/cache_folder_iterator branch from 21d7b9f to 1282816 Compare January 29, 2026 15:21
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
@Altahrim Altahrim force-pushed the feat/cache_folder_iterator branch from 1282816 to d7e81e7 Compare January 29, 2026 15:45
* @return iterable<ICacheEntry>
* @since 34.0.0
*/
public function iterateFolderContentsById(int $fileId, bool $includeMetadata = false, bool $sortByName = false): iterable;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that getFolderContentsById() does not support those parameters, are $includeMetadata and $sortByName really useful?

Also, you touched a comment suggesting that having a mimetype parameter would be nice.

Copy link
Collaborator Author

@Altahrim Altahrim Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These parameters are optimisations for the underlying query. If we don't use metadata, better avoid the join. If we don't need sorted elements, better leave default order.

From what I've found, the mimetype filter is not really used. That's why I didn't implemented it, but I can :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should think about another kind of API… Something like:

// Similar to getFolderContentsById()
$cache->iterateById($folderId)->withMetadata()->sortBy(ICache::SORT_NAME)->exec();
// Unsorted list of ID
$cache->iterateById($folderId)->asType(ICache::RESULT_ID)->exec();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another though, adding those kinds of arguments/filters sounds more like a search than a listing. So if those are actually useful, maybe we could name the new method something like searchFolderContentsById.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🏗️ In progress

Development

Successfully merging this pull request may close these issues.

3 participants