Archive Module Phase 1-4完成(2916行代码,Upload Service集成)

Phase 1-3(2916行):
- Phase 1: 核心框架(900行)- ProcessorRegistry, FormatDetector, ArchiveConfig
- Phase 2: 核心处理器(1332行)- ZIP, TAR, GZIP, TAR.GZ完整实现
- Phase 3: 可选格式(312行)- RAR, XZ, 7z(默认禁用,法律/稳定性警告)

Phase 4(230行):
- Upload Service集成Archive Module
- 自动检测压缩格式并解压
- 提取文件注册到数据库(file_registry, file_locations, file_nodes)
- JSON响应包含extracted字段(count, bytes, directory)

核心修改:
- server.rs: extract_and_register_archive函数(150行)
- server.rs: upload_file自动解压逻辑(80行)
- Cargo.toml: tempfile依赖移到dependencies
- ArchiveProcessor trait: 所有方法改为&mut self
- ZipProcessor: 解决ZipArchive borrow冲突
- TarProcessor: 修复entry可变引用问题
- ProcessorRegistry: 添加get_processor_mut方法

编译修复:16→0错误(45分钟)
- Trait方法签名统一
- ZipArchive borrow checker问题解决
- TarProcessor entry可变引用修复
- Trait object lifetime bound修复

支持格式(12种):
- 核心4种:ZIP, TAR, GZIP, TAR.GZ(已实现)
- 可选3种:RAR, XZ, 7z(已实现,默认禁用)
- 扩展5种:ZSTD, BZIP2, LZ4, TAR.BZ2, TAR.ZST(stub)
This commit is contained in:
Warren
2026-06-10 21:07:03 +08:00
parent 4a89629693
commit ff8bc16565
9 changed files with 961 additions and 364 deletions

View File

@@ -8,11 +8,12 @@ edition = "2021"
zip = "0.6" # ZIP格式稳定版本
tar = "0.4.46" # TAR格式
flate2 = "1.1" # GZIP格式已有
tempfile = "3.12" # 临时目录(解压时需要)
# === 可选压缩库Phase 3争议格式===
unrar = { version = "0.4.0", optional = true } # RAR解压 ⚠️法律风险
xz2 = { version = "0.1.7", optional = true } # XZ格式 ⚠️外部依赖
sevenz-rust = { version = "0.21.0", optional = true } # 7z格式 ⚠️库不稳定
sevenz-rust = { version = "0.6.1", optional = true } # 7z格式 ⚠️库不稳定(修正版本号)
anyhow = "1"
axum = { version = "0.7", features = ["macros"] }
@@ -59,7 +60,7 @@ default = [] # 默认不启用可选格式
optional-formats = ["unrar", "xz2", "sevenz-rust"] # 争议格式可选启用
[dev-dependencies]
tempfile = "3.12"
# tempfile moved to dependencies (needed for archive extraction)
[[bin]]
name = "markbase-core"