所以应该比较 relative_path 而不是 filename
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user