Skip to content

[BUG] 数据库搜索索引无法删除已不存在的文件,刷新目录后仍能搜索到 #2880

Description

@Gloduck

Please confirm the following

  • I have read and agree to AGPL-3.0 Section 15 .
    The program is provided "as is" without any warranties; you bear all risks of using it.

  • I have read and agree to AGPL-3.0 Section 16 .
    The copyright holders and distributors are not liable for any damages resulting from the use or inability to use the program.

  • I confirm my description is clear, polite, helps developers quickly locate the issue, and complies with community rules.

  • I have read the OpenList documentation.

  • I confirm there are no duplicate issues or discussions.

  • I confirm this is an OpenList issue, not caused by other reasons (such as network, dependencies, or operation).

  • I believe this issue must be handled by OpenList and not by a third party.

  • I confirm this issue is not fixed in the latest version.

  • I have not read these checkboxes and therefore I just ticked them all, Please close this issue.

OpenList Version (required)

v4.2.3 (Commit: a92d59d) - Frontend: v4.2.3

Storage Driver Used (required)

115

Bug Description (required)

问题现象

OpenList 使用数据库搜索索引,并已开启“自动更新索引”。

索引中原本存在文件:

/115/测试.txt

该文件从底层存储删除后,在 OpenList 中进入 /115 目录并点击页面右下角的刷新按钮。目录列表已经确认从底层存储重新获取,文件也不再显示,但通过 OpenList 搜索仍然可以搜索到 /115/测试.txt

删除后已等待较长时间,并多次强制刷新 /115 目录,旧搜索结果仍然存在。点击该搜索结果访问文件时,底层存储返回 object not found,说明文件确实已经删除,搜索结果是残留的索引记录。

完整重新构建索引可以清理该记录,但目录强制刷新触发的增量索引更新无法删除它。

复现步骤

  1. 使用数据库搜索索引,并开启“自动更新索引”。
  2. 完整构建一次索引。
  3. 在某个已建立索引的目录中创建文件,例如 /115/测试.txt
  4. 确认该文件可以通过 OpenList 搜索找到。
  5. 删除该文件。
  6. 进入 /115 目录,点击页面右下角 tips="refresh" 的刷新按钮。
  7. 确认目录列表中已经没有 测试.txt
  8. 等待一段时间后,在 OpenList 中搜索 测试.txt
  9. 搜索结果仍然包含 /115/测试.txt
  10. 点击该搜索结果,日志显示文件 object not found

实际结果

目录刷新后,文件已经从目录列表消失,但对应的数据库搜索索引记录没有被删除。该文件会一直出现在搜索结果中,直到执行完整索引重建。

预期结果

强制刷新目录并从底层存储取得最新目录列表后,增量索引更新应当删除该目录下已经不存在的文件索引。

Logs (required)

17231:[GIN] 2026/07/31 - 03:10:29 | 200 | 1.58s | 171.221.219.39 | GET "/p/115/测试.txt?openlist_ts=1785467427113"
17236:ERRO[2026-07-31 03:10:37] failed link /115/测试.txt: object not found
17295:[GIN] 2026/07/31 - 03:10:37 | 500 | 4.12ms | 171.221.219.39 | GET "/p/115/测试.txt?openlist_ts=1785467436322"
17296:ERRO[2026-07-31 03:10:37] failed link /115/测试.txt: object not found
17355:[GIN] 2026/07/31 - 03:10:37 | 500 | 1.72ms | 171.221.219.39 | GET "/p/115/测试.txt"
17358:ERRO[2026-07-31 03:10:46] failed link /115/测试.txt: object not found
17417:[GIN] 2026/07/31 - 03:10:46 | 500 | 1.28ms | 171.221.219.39 | GET "/p/115/测试.txt?openlist_ts=1785467445788"
17418:ERRO[2026-07-31 03:10:46] failed link /115/测试.txt: object not found
17477:[GIN] 2026/07/31 - 03:10:46 | 500 | 350.18µs | 171.221.219.39 | GET "/p/115/测试.txt"

Configuration File Content (required)

部署方式:Docker

OpenList 镜像:

openlistteam/openlist:latest

运行版本:

v4.2.3 (Commit: a92d59d) - Frontend: v4.2.3

数据库:

{
  "database": {
    "type": "postgres",
    "db_file": ""
  }
}

### Reproduction Link (optional)

_No response_

### AI Generated Content (optional)

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidInvalid Content/Cannot Reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions