Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
猿人易 committed Dec 7, 2024
2 parents 0ffba7f + 800b5dc commit d7a7919
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Pek.AspNetCore/Helpers/DHWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -827,12 +827,6 @@ public static async Task DownloadLinkAndExtract(String url, String name, String
var savePath = destdir.CombinePath(name); // 替换为你想保存的路径
savePath.EnsureDirectory();

var saveFile = savePath.AsFile();
if (saveFile.Exists)
{
saveFile.Delete();
}

var sw = Stopwatch.StartNew();
var responseData = await Client().Get(UrlHelper.Combine(url, name)).DownloadDataAsync().ConfigureAwait(false);
sw.Stop();
Expand All @@ -843,9 +837,15 @@ public static async Task DownloadLinkAndExtract(String url, String name, String
return;
}

FileUtil.Write(savePath, responseData!); // 保存文件
var saveFile = savePath.AsFile();
if (saveFile.Exists)
{
saveFile.Delete();
}

FileUtil.Write(savePath, responseData); // 保存文件

XTrace.Log.Info("下载完成,共{0:n0}字节,耗时{1:n0}毫秒", saveFile.Length, sw.ElapsedMilliseconds);
XTrace.Log.Info("下载完成,共{0:n0}字节,耗时{1:n0}毫秒", savePath.AsFile().Length, sw.ElapsedMilliseconds);

savePath.AsFile().Extract(destdir, overwrite);

Expand Down

0 comments on commit d7a7919

Please sign in to comment.