所以应该比较 relative_path 而不是 filename

This commit is contained in:
zqm
2026-04-10 14:25:46 +08:00
parent 457e5c5333
commit 5fdd3c33d0

View File

@@ -861,11 +861,14 @@ fn handle_app_file_chunk(
let mut app_map = ctx.app_download_map.lock().unwrap();
// 获取当前正在下载的文件名(用于判断是否是新文件)
// 注意app_map 中存储的 filename 是不含前缀的 relative_path
let current_filename = app_map.values().next().map(|s| s.filename.clone());
// 新文件(非续传):清空旧 entry等待 DownloadComplete 处理旧文件
// 续传(同一文件 + 非零 offset追加数据不清 entry
if current_filename.as_ref() != Some(&filename.to_string()) && (!app_map.contains_key(&key) || offset == 0) {
// 注意:current_filename 来自 app_map不含前缀filename 来自服务端(含前缀)
// 所以应该比较 relative_path 而不是 filename
if current_filename.as_ref() != Some(&relative_path) && (!app_map.contains_key(&key) || offset == 0) {
if let Some(f) = app_map.get_mut(&key) {
if let Some(file) = f.file.take() {
drop(file);