Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit08002ef

Browse files
committed
fix: fix Downloader to always dispose of temp file stream
1 parenta58864e commit08002ef

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

‎Vpn.Service/Downloader.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -453,27 +453,26 @@ private async Task Start(CancellationToken ct = default)
453453
if(res.Content.Headers.ContentLength>=0)
454454
TotalBytes=(ulong)res.Content.Headers.ContentLength;
455455

456-
FileStreamtempFile;
457-
try
458-
{
459-
tempFile=File.Create(TempDestinationPath,BufferSize,
460-
FileOptions.Asynchronous|FileOptions.SequentialScan);
461-
}
462-
catch(Exceptione)
463-
{
464-
_logger.LogError(e,"Failed to create temporary file '{TempDestinationPath}'",TempDestinationPath);
465-
throw;
466-
}
467-
468-
awaitDownload(res,tempFile,ct);
456+
awaitDownload(res,ct);
469457
return;
470458
}
471459

472-
privateasyncTaskDownload(HttpResponseMessageres,FileStreamtempFile,CancellationTokenct)
460+
privateasyncTaskDownload(HttpResponseMessageres,CancellationTokenct)
473461
{
474462
try
475463
{
476464
varsha1=res.Headers.Contains("ETag")?SHA1.Create():null;
465+
FileStreamtempFile;
466+
try
467+
{
468+
tempFile=File.Create(TempDestinationPath,BufferSize,
469+
FileOptions.Asynchronous|FileOptions.SequentialScan);
470+
}
471+
catch(Exceptione)
472+
{
473+
_logger.LogError(e,"Failed to create temporary file '{TempDestinationPath}'",TempDestinationPath);
474+
throw;
475+
}
477476
awaitusing(tempFile)
478477
{
479478
varstream=awaitres.Content.ReadAsStreamAsync(ct);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp