Skip to content

fix(knowledge): read PDF via get_buffer for zip members - #7695

Closed
ump45nose wants to merge 1 commit into
1Panel-dev:v2from
ump45nose:fix/7436-zip-pdf-split-v2
Closed

ump45nose wants to merge 1 commit into
1Panel-dev:v2from
ump45nose:fix/7436-zip-pdf-split-v2

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

Summary

Fixes #7436.

PDF-only zip uploads previously produced an empty split list. PdfSplitHandle historically called UploadedFile.chunks(), which ZipExtFile does not provide; ZipSplitHandle then swallowed the error.

On current v2 there is already an hasattr(file, \"chunks\") / shutil.copyfileobj fallback. This PR goes one step further and always writes the temp file from get_buffer(file), matching Doc/HTML/XLSX handlers and the FileBufferHandle cache that ZipSplitHandle already builds for each member.

Test plan

  • Local review of the get_buffer write path
  • Added apps/common/handle/impl/text/tests/test_pdf_zip_buffer.py (ZipExtFile-like object without chunks(); mocks PdfReader / TOC)
  • Maintainers: upload a PDF-only zip in the knowledge UI and confirm paragraphs appear

AI disclosure

This pull request was prepared with assistance from an autonomous coding agent (Grok Bot). I reviewed the diff and take responsibility for the change.

Note: #7694 was opened against main by mistake and closed; this PR targets v2.

PdfSplitHandle still preferred UploadedFile.chunks() and only fell back to
copyfileobj. Routing through get_buffer matches Doc/HTML/XLSX and keeps
ZipExtFile members (issue 1Panel-dev#7436) on the same cached-buffer path used by
ZipSplitHandle.

Fixes 1Panel-dev#7436
@liuruibin liuruibin closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 知识库上传包含 PDF 的 zip 压缩包后分段结果为空

2 participants