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

未关闭 适合新手
#4,446 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
swift
领域
mobile

调研方向

从 issue 中描述的 iOSClient/Main/Collection Common/NCCollectionViewCommon+Search.swift 里的 getSearchResultMetadatas default 分支开始。追踪同时具有 fileId 和 filePath 的条目是如何处理的,然后检查附近搜索测试的覆盖情况。当本地已知且带有这两个属性返回的文件在 provider 部分只出现一次时,即为完成。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Swift
星标
2.5k
派生
1k
平均合并
1 天 16 小时
30 天内合并 PR
23

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nextcloud/ios 的其他 Issue

查看 nextcloud/ios 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。