Thumbnails duplications, missing thumbnails and files failing to download
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 50/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
⚠️ 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.
- Lingua principale
- Kotlin
- Stelle
- 5.7k
- Fork
- 2.1k
- Merge medio
- 1g 22h
- PR unite (30g)
- 135
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nextcloud/android
-
0. Needs triage bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
nextcloud/android#17845 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Lock owned by another client (e.g. Text app) cannot be unlocked from the appForse già presa @falkloewert l’ha presa 28 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
nextcloud/android#17837 · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
0. Needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
nextcloud/android#17533 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
RC 34.1.0-01: Duplicated wording in creation menu — "New" prefix + creator name produces "New New document" ("Neu Neues Dokument")Forse già presa @ChristianTannheimer l’ha presa 118 giorni fa. Aperta0. Needs triage bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di nextcloud/android
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Kotlin/kotlin-lsp#309 ·
-
Two stored artist rows are not act names: "DJS" from a Renate floor heading and "Stevie Cox -"Apertaarea:data-quality importer size:S
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
enorm-labs/event-junkie#5136 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Type: Possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
spacecowboy/Feeder#1318 ·
I maintainer di solito rispondono entro 1 giorno
-
个人助手回复内容既无法手动选中复制,也没有一键复制Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
wangzan101/Mika#644 ·
I maintainer di solito rispondono entro 1 giorno