nextcloud / nextcloud/ios

Media tab repeatedly rebuilds index from 0 while local Documents & Data cache still exists

Open
#4,094 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Swift
Stars
2.5k
Forks
1k
Avg merge
2d 18h
Merged PRs (30d)
13

Description

Bug description

The iOS app repeatedly rebuilds the Media tab index from scratch, even though the local app data/cache is still present.

I have a large media library with tens of thousands of images/videos. After the Media tab has already finished indexing/caching media once, opening the app or entering the Media tab sometimes shows the media cache/index starting again from 0, as if no media had been cached before.

However, iOS storage still shows that Nextcloud keeps several GB of "Documents & Data". This suggests that the actual local cached files/data are not deleted. Instead, the local media index/database or Media tab data source seems to be cleared, reset, or filtered as empty.

Current behavior

  1. Media tab previously contains a large number of indexed media items.
  2. After reopening the app or entering the Media tab again, the media count/indexing progress starts from 0.
  3. The app begins rebuilding the Media tab cache/index again.
  4. iOS Settings still shows the Nextcloud app has large "Documents & Data" storage usage.
  5. Therefore, the local cached data appears to still exist, but the Media tab does not reuse it.

Expected behavior

The Media tab should reuse the existing local media index/cache if the cached files and metadata are still present.

A temporary empty server-side SEARCH result, failed request, changed media path, capability mismatch, or network issue should not cause the existing local Media tab data source/index to be cleared.

Actual behavior

The Media tab behaves as if the local media index is empty and starts rebuilding from 0, while the app storage size remains almost unchanged.

Environment

  • App: Nextcloud iOS
  • Version: 33.0.7
  • Device: iPhone
  • iOS language: Chinese
  • Media library size: tens of thousands of media items
  • iOS storage shows:
    • App size: about 237.7 MB
    • Documents & Data: about 6.89 GB

Possible cause

This looks like an index/database reset rather than an actual cache deletion.

From the code, the Media tab seems to rely on local metadata/data source rather than directly scanning the existing local cached files.

One suspicious area may be the Media tab search/index refresh logic. In NCMediaDataSource.swift, if the full-range media search returns no files, the current data source may be cleared:

Image Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in NCMediaDataSource.swift and trace the Media tab search/index refresh path, especially what happens when a full-range media search returns no files. Reproduce with an existing local cache and check whether a temporary empty result clears the local data source. Done means the Media tab reuses existing cached metadata instead of restarting indexing from 0 when cached files remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.