🟡 P2 | detect_material_type 读整个文件只为检测魔数 #41

Closed
opened 2026-06-06 12:33:02 +08:00 by wangdl · 1 comment
Owner

背景

detect_material_type 中 std::fs::read(file_path) 将整个文件读入内存,仅用前几个字节做魔数检测。对 PDF/大图片是浪费。

修复方案

只读前 8192 字节:let mut buf = vec![0u8; 8192]; file.read(&mut buf)

位置

crates/zx_document_core/src/material_type.rs:51

## 背景 detect_material_type 中 std::fs::read(file_path) 将整个文件读入内存,仅用前几个字节做魔数检测。对 PDF/大图片是浪费。 ## 修复方案 只读前 8192 字节:let mut buf = vec![0u8; 8192]; file.read(&mut buf) ## 位置 crates/zx_document_core/src/material_type.rs:51
wangdl added this to the M6:Code Review 质量完善(2026-06-06) milestone 2026-06-06 12:33:02 +08:00
Author
Owner

修复完成 (2026-06-06)

实现

std::fs::read(读整个文件)→ File::open + read 前 8192 字节

状态

已修复。

## 修复完成 (2026-06-06) ### 实现 `std::fs::read`(读整个文件)→ `File::open` + `read` 前 8192 字节 ### 状态 ✅ 已修复。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/zhixi-document-runtime#41
No description provided.