Thumbnails duplications, missing thumbnails and files failing to download
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 50/100
調査の方向性
Start from the issue's root-cause analysis pointing to race conditions in FileDataStorageManager.java and thumbnail size bugs in DocumentsStorageProvider.kt. Read those plus DocumentLister.kt, DiskLruImageCacheFileProvider.java and ThumbnailsCacheManager.java to understand the storage and caching flow. Done means no duplicate file rows, correct thumbnail sizes, and cached thumbnails keyed by remoteId.
索引モデルが issue の本文から書いたものです。
説明
⚠️ Before posting ⚠️
- This is a bug, not a question or an enhancement.
- I've searched for similar issues and didn't find a duplicate.
- I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
- I agree to follow Nextcloud's Code of Conduct.
Steps to reproduce
- Open Discord
- Click share file
- In share popup choose Nextcloud
- Navigate to folder full of images
Expected behaviour
- All thumbnails load(preferably from cache)
- Same files do not appear more than once
- Files can be shared
Actual behaviour
- Some thumbnails never work
- Some files appear twice
- Some files fail to sync/share
Android version
16
Device brand and model
Samsung Galaxy S10+
Stock or custom OS?
Custom (explain in "additional information")
Nextcloud android app version
35.0.2
Nextcloud server version
26
Using a reverse proxy?
Yes
Android logs
No response
Server error logs
Additional information
My OS is lineage OS. There is no file at storage/emulated/0/data/nextcloud.log.
I had these 3 issues for a while. I suspect that they are at least partially because of me using adb to just pull and push all the files when changing phone, but some of these issues like broken thumbnails were older than that. I tasked Deepseek with debugging these issues and it found couple of problems with both with the state of files on my phone and code itself. In particular, it seems there is a race condition that causes duplications in file database and wrong thumbnail size reporting which breaks thumbnails for files smaller than the thumbnail. I am not going to pretend to be experienced in Java nor your codebase, but I've pushed commit that fixes code issues to my fork. It's fairly short so you might find it useful, but take it with grain of salt(claude had some concerns on the quality of this fix). https://github.com/funmaker/nextcloud_android/commit/c8c7f754c2319c10e7c610a5d3211f78f034e306
Here is a more in detail description from Deepseek agent:
Investigated all three against the live device, server, app database, and source.
Root causes
1. Duplicate files in /xD/reaction/
The file database itself contained duplicate rows, not the server. For example:
_id 1800 /xD/reaction/001.jpg remote_id 00427388...
_id 2086 /xD/reaction/001.jpg remote_id 00427388...
There were 354 duplicate-path groups (580 rows for 292 files in /xD/reaction/).
I reproduced the creation mechanism: forcing two concurrent queryChildDocuments() calls on the same stale folder started two RefreshFolderOperations at once. Both took a database snapshot before either saved, both saw the file as “new”, and both inserted it. FileDataStorageManager.saveFolder() does a check-then-insert without serialization, so it is a race.
2. Broken/missing thumbnails
Two bugs:
- DocumentsStorageProvider.openDocumentThumbnail() returned a generated PNG thumbnail but told the caller its length was file.fileLength — the original file size. Small images often have thumbnails larger than the original, so the thumbnail was truncated and failed to decode. Example: /xD/reaction/001.jpg is 13,645 bytes, but its generated thumbnail file was 60,533 bytes; only 13,645 bytes were exposed.
- DiskLruImageCacheFileProvider.getParcelFileDescriptorForOCFile() called Files.createFile() and only wrote the bitmap inside the same try. If the cache file already existed, createFile() threw and the write was skipped, leaving stale/old thumbnail data forever. Cache files were also keyed only by base filename, so equal filenames in different folders collided.
- Additionally ThumbnailsCacheManager.containsBitmap() dereferenced the disk cache before its async initialization finished, and addBitmapToCache() silently dropped images during startup, so first thumbnails were not cached.
3. /xD/reaction/111665930_..._n.png cannot be opened/shared
This was a device MediaProvider ownership problem, not a Nextcloud logic bug.
The file was registered in MediaProvider’s external.db as:
owner_package_name = com.android.shell
while the app is com.nextcloud.client. The app therefore got EACCES when opening/replacing it. 352 of 593 files under the Nextcloud media directory had the same wrong owner. Because the DB row had an empty etag, DocumentOpener also tried to re-download it; the HTTP download succeeded, but Files.move(..., REPLACE_EXISTING) then failed with EACCES, and opening the existing local file failed too.
Changes made
Source changes in the working tree:
- DocumentLister.kt
- Deduplicates listed/search results by remoteId / decrypted path.
- Coalesces concurrent folder reload jobs per document so repeated queryChildDocuments() calls do not start parallel refreshes.
- FileDataStorageManager.java
- Serializes saveFolder() through a process-wide lock, eliminating the check-then-insert race that created duplicate rows.
- DocumentsStorageProvider.kt
- Returns the actual thumbnail file size via descriptor.statSize instead of the original document size.
- DiskLruImageCacheFileProvider.java
- Always overwrites the generated thumbnail, uses a unique thumbnail filename (remoteId), and reports the real file.
- ThumbnailsCacheManager.java
- containsBitmap() now waits for disk-cache initialization and is null-safe.
- addBitmapToCache() waits for initialization instead of silently dropping thumbnails.
Device fixes applied
- Removed 354 duplicate filelist rows and reparented any affected children. Verified PRAGMA integrity_check = ok; /xD/reaction/ now returns 292 rows, no duplicates.
- Backup left at /data/local/tmp/filelist-before-dedupe.db.
- Repaired MediaProvider ownership for all 593 Nextcloud media files (com.android.shell / old ownership → com.nextcloud.client), preserving the files_update trigger and restarting MediaProvider.
- Deleted and re-downloaded the originally failing 111665930_..._n.png.
Verified content read now succeeds for:
- /xD/reaction/001.jpg — 13,645 bytes
- /xD/reaction/111665930_316871886117476_1713782649053830776_n.png — 92,032 bytes
- /xD/reaction/1708011767812109.jpg — 39,491 bytes
Status / caveat
The device-side duplicate cleanup and MediaProvider repair take effect immediately. The source fixes for duplicate prevention and thumbnails require rebuilding/reinstalling the APK; this environment has no Android SDK/AGP cache, so I could not compile or install the patched build here. The changes are uncommitted for human review as required by the project’s AI contribution policy.
Build · DeepSeek V4.1 Flash · 37m 33s · 47.8 tok/s
After these devices fixes and rebuilding the app for my device all the issues were resolved.
- 主要言語
- Kotlin
- スター
- 5.7k
- フォーク
- 2.1k
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 135
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/android のほかの issue
-
0. Needs triage bug
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
nextcloud/android#17845 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] Lock owned by another client (e.g. Text app) cannot be unlocked from the app対応中かも @falkloewert が 28 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nextcloud/android#17837 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
0. Needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
nextcloud/android#17533 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
RC 34.1.0-01: Duplicated wording in creation menu — "New" prefix + creator name produces "New New document" ("Neu Neues Dokument")対応中かも @ChristianTannheimer が 118 日前に担当しました。 オープン0. Needs triage bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
nextcloud/android の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Kotlin/kotlin-lsp#309 ·
-
area:data-quality importer size:S
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
enorm-labs/event-junkie#5136 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
Type: Possible bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
spacecowboy/Feeder#1318 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
wangzan101/Mika#644 ·
メンテナーはふだん 1 日以内に返信