mirror of
https://github.com/bolucat/Archive.git
synced 2025-09-26 20:21:35 +08:00
Update On Sat Sep 6 20:35:54 CEST 2025
This commit is contained in:
@@ -26,8 +26,14 @@ internal static class BBDownDownloadUtil
|
||||
private static async Task RangeDownloadToTmpAsync(int id, string url, string tmpName, long fromPosition, long? toPosition, Action<int, long, long> onProgress, bool failOnRangeNotSupported = false)
|
||||
{
|
||||
DateTimeOffset? lastTime = File.Exists(tmpName) ? new FileInfo(tmpName).LastWriteTimeUtc : null;
|
||||
using var fileStream = new FileStream(tmpName, FileMode.Create);
|
||||
using var fileStream = new FileStream(tmpName, FileMode.OpenOrCreate);
|
||||
fileStream.Seek(0, SeekOrigin.End);
|
||||
if (toPosition > 0 && fileStream.Position == toPosition - fromPosition + 1)
|
||||
{
|
||||
// 已下载完成 直接汇报进度并跳过下载
|
||||
onProgress(id, fileStream.Position, fileStream.Position);
|
||||
return;
|
||||
}
|
||||
var downloadedBytes = fromPosition + fileStream.Position;
|
||||
|
||||
using var httpRequestMessage = new HttpRequestMessage();
|
||||
|
@@ -503,8 +503,6 @@ internal partial class Program
|
||||
{
|
||||
if (downloadConfig.MultiThread && !url.Contains("-cmcc-"))
|
||||
{
|
||||
// 下载前先清理残片
|
||||
foreach (var file in new DirectoryInfo(Path.GetDirectoryName(destPath)!).EnumerateFiles("*.?clip")) file.Delete();
|
||||
await MultiThreadDownloadFileAsync(url, destPath, downloadConfig);
|
||||
Log($"合并{(video ? "视频" : "音频")}分片...");
|
||||
CombineMultipleFilesIntoSingleFile(GetFiles(Path.GetDirectoryName(destPath)!, $".{(video ? "v" : "a")}clip"), destPath);
|
||||
|
@@ -93,10 +93,9 @@ class ProgressBar : IDisposable, IProgress<double>
|
||||
if (disposed) return;
|
||||
|
||||
int progressBlockCount = (int)(currentProgress * blockCount);
|
||||
int percent = (int)(currentProgress * 100);
|
||||
string text = string.Format(" [{0}{1}] {2,3}% {3}{4}",
|
||||
new string('#', progressBlockCount), new string('-', blockCount - progressBlockCount),
|
||||
percent,
|
||||
double percent = currentProgress * 100;
|
||||
string text = string.Format(" [{0}{1}] {2,3:0.00}% {3}{4}",
|
||||
new string('#', progressBlockCount), new string('-', blockCount - progressBlockCount), percent,
|
||||
animation[animationIndex++ % animation.Length],
|
||||
speedString);
|
||||
UpdateText(text);
|
||||
|
Reference in New Issue
Block a user