🟡 P2 | detect_material_type 读整个文件只为检测魔数 #41
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
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
修复完成 (2026-06-06)
实现
std::fs::read(读整个文件)→File::open+read前 8192 字节状态
✅ 已修复。