Skip to content

Commit b79fb5e

Browse files
author
shawnnqin
committed
修复mono runtime下调用高级下载 Pause & Resume 接口偶发下载失败的问题
1 parent c2780e5 commit b79fb5e

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

QCloudCSharpSDK/COSXML/Transfer/COSXMLDownloadTask.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ internal void Download()
224224
}
225225
// concurrent download
226226
ConcurrentGetObject(result.crc64ecma);
227-
}
227+
}
228228

229229
},
230230

@@ -462,8 +462,9 @@ private void ConcurrentGetObject(string crc64ecma)
462462
return;
463463
}
464464
// 对客户端异常, 全部都重试
465-
if (clientEx != null)
465+
if (clientEx != null) {
466466
gClientExp = clientEx;
467+
}
467468
resetEvent.Set();
468469
}
469470
);
@@ -528,7 +529,7 @@ 超出 singleTaskTimeoutMs 时,全部清理掉进入下一轮重试
528529
}
529530
}
530531
return;
531-
}
532+
}
532533
// 预期每个分块都下载完成了, 开始顺序合并
533534
FileMode fileMode = FileMode.OpenOrCreate;
534535
FileInfo localFileInfo = new FileInfo(localDir + localFileName);
@@ -672,18 +673,10 @@ private void RealCancle()
672673
// 停止可能进行中的Head请求
673674
cosXmlServer.Cancel(headObjectRequest);
674675
// 停止可能进行中的下载线程
675-
Interlocked.Decrement(ref activeTasks);
676676
foreach (GetObjectRequest subGetObjectRequest in getObjectRequestsList) {
677677
cosXmlServer.Cancel(subGetObjectRequest);
678678
}
679-
activeTasks = 0;
680-
/*
681-
// wait for tasks to finish
682-
while (activeTasks > 0)
683-
{
684-
Thread.Sleep(100);
685-
}
686-
*/
679+
getObjectRequestsList.Clear();
687680
}
688681

689682
private void Clear()
@@ -711,7 +704,7 @@ public override void Pause()
711704
{
712705
//exit download
713706
lock (syncExit)
714-
{
707+
{
715708
isExit = true;
716709
}
717710
//cancle request

0 commit comments

Comments
 (0)