Unified search shows a file twice when a provider entry has both fileId and path

Aperta Adatta ai principianti
#4,446 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
swift
Ambito
mobile

Direzione di ricerca

Inizia in iOSClient/Main/Collection Common/NCCollectionViewCommon+Search.swift, nel ramo default di getSearchResultMetadatas descritto nella issue. Segui la gestione delle voci con sia fileId che filePath, poi verifica la copertura nei test di ricerca vicini. Il lavoro è completato quando un file noto localmente, restituito con entrambi gli attributi, compare una volta nella sezione del provider.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

How to use GitHub
  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce
  1. Have a unified search provider, other than files, whose entries carry both a fileId and a path attribute. Seen with paperless_unified_search 1.3.0.
  2. Open a file in the app, or the folder holding it, so the file is in the app's local database.
  3. Search for a term that returns that file from the provider.
Expected behaviour

The file appears once in the provider's section.

Actual behaviour

The same file appears twice in the provider's section. Both rows show the same folder.

Logs

The cause looks like the default: branch of getSearchResultMetadatas in iOSClient/Main/Collection Common/NCCollectionViewCommon+Search.swift (tag 35.2.2; the same code is on master):

if let fileId = entry.fileId,
   let metadata = database.getMetadataFromFileId(String(fileId), account: session.account) {
    metadata.section = provider.name
    metadatas.append(metadata)      // first append, no continue
}

if let filePath = entry.filePath,
   let metadata = await loadMetadata(session: session,
                                     provider: provider,
                                     filePath: filePath) {
    metadatas.append(metadata)      // second append of the same file
    continue
}

The first if has no continue, so an entry whose file is already known locally is appended by ID and then again by path. A continue after the first append looks like the fix.

What I checked:

  • The server sends one entry. The provider's response for the term held entries of length 1, with {"fileId": "...", "path": "/.../file.pdf"} in attributes.
  • The file exists once in the server's file cache.
  • Removing the fileId attribute on the server leaves one entry with only path, which should take only the second branch. I have not yet confirmed that on the device.

I found this by reading the source, with help from Claude Code. I did not build the app or run it under a debugger.

Reasoning or why should it be changed/implemented?

Any provider that returns real files can show each previously opened file twice, which reads as a duplicate on the server.

Environment data

iOS version: not recorded

Nextcloud iOS app version: 35.2.2

Server operating system: Debian 13 (Nextcloud Docker image)

Web server: Apache 2.4

Database: PostgreSQL 18

PHP version: 8.5.12

Nextcloud version: 35.0.2

Lingua principale
Swift
Stelle
2.5k
Fork
1k
Merge medio
2g 1h
PR unite (30g)
21

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nextcloud/ios

Tutte le issue di nextcloud/ios

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.