Skip to content

[ISSUE] Preview cache is keyed by basename only, causing content pollution between different files that share a filename #791

Description

@gozimi

Issue Type / 问题类型

Bug / 缺陷

kkFileView Version / kkFileView 版本

5.0.2

Deployment Mode / 部署方式

docker built from source via the official Dockerfile

Environment / 环境信息

Description

Converted preview artifacts under file.dir are named after the source file's basename only — no source path and no hash of the full URL is included. Because of this, two different files from different paths (or different storage backends) that happen to share the same filename write their converted output to the same physical path, overwriting each other.

Steps to Reproduce / 复现步骤

  1. Prepare two files with the same name but different content, served from two different URLs, e.g. .../pathA/test.docx (content "AAAA") and .../pathB/test.docx (content "BBBB").
  2. Preview .../pathA/test.docx via onlinePreview → confirms "AAAA".
  3. Preview .../pathB/test.docx → confirms "BBBB".
  4. Preview .../pathA/test.docx again.

Expected Result / 期望结果

Still shows "AAAA".

Actual Result / 实际结果

Shows "BBBB" — pathA's cached entry now serves pathB's converted file, because both conversions wrote to the same output filename on disk.

Suspected cause

The cache lookup appears to be keyed by the full request URL, but the converted file's on-disk name is derived only from the URL's last path segment (the original filename), so the URL-based cache key and the physical output path are not consistently tied together. Any two source URLs with the same trailing filename will collide.

Suggested fix

Derive the on-disk output filename from a hash (e.g. short MD5/SHA1) of the full source URL, or otherwise namespace the output path per source URL, instead of using only the trailing filename segment. This preserves human-readable names while guaranteeing uniqueness across paths.

This is a real concern for any deployment that fronts multiple storage backends/paths with overlapping filenames (e.g. behind AList, Alfresco, or similar multi-tenant file browsers), since it can silently serve one user's document content to another.

Logs & Screenshots / 日志与截图

N/A

Sample File / 样例文件(可选)

No response

Checklist / 提交前检查

  • I have searched existing issues and did not find a duplicate. / 我已搜索现有 issue,未发现重复问题
  • I can reproduce this issue on the stated version/environment. / 我可在上述版本与环境复现该问题
  • I have masked sensitive information in logs/screenshots. / 我已对日志与截图中的敏感信息做脱敏处理

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/needs-infoWaiting for reporter feedback or reproduction details

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions