Skip to content

Commit 5f611d9

Browse files
committed
code_style: make sure that all Stream objects will be disposed immediately after operation finished
Signed-off-by: leo <longshuang@msn.cn>
1 parent f7a4e66 commit 5f611d9

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/Commands/SaveRevisionFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static async Task RunAsync(string repo, string revision, string file, str
1616
var isLFSFiltered = await new IsLFSFiltered(repo, revision, file).GetResultAsync().ConfigureAwait(false);
1717
if (isLFSFiltered)
1818
{
19-
var pointerStream = await QueryFileContent.RunAsync(repo, revision, file).ConfigureAwait(false);
19+
await using var pointerStream = await QueryFileContent.RunAsync(repo, revision, file).ConfigureAwait(false);
2020
await ExecCmdAsync(repo, "lfs smudge", saveTo, pointerStream).ConfigureAwait(false);
2121
}
2222
else

src/ViewModels/CommitDetail.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ private async Task SetViewingBlobAsync(Models.Object file)
694694
return;
695695
}
696696

697-
var contentStream = await Commands.QueryFileContent.RunAsync(_repo.FullPath, _commit.SHA, file.Path);
697+
await using var contentStream = await Commands.QueryFileContent.RunAsync(_repo.FullPath, _commit.SHA, file.Path);
698698
var content = await new StreamReader(contentStream).ReadToEndAsync();
699699
var lfs = Models.LFSObject.Parse(content);
700700
if (lfs != null)

src/ViewModels/FileHistories.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private async Task<object> GetRevisionFileContentAsync(Models.Object obj)
131131
return new FileHistoriesRevisionFile(_file, binaryFile, true);
132132
}
133133

134-
var contentStream = await Commands.QueryFileContent.RunAsync(_repo, _revision.SHA, _file).ConfigureAwait(false);
134+
await using var contentStream = await Commands.QueryFileContent.RunAsync(_repo, _revision.SHA, _file).ConfigureAwait(false);
135135
var content = await new StreamReader(contentStream).ReadToEndAsync();
136136
var lfs = Models.LFSObject.Parse(content);
137137
if (lfs != null)

0 commit comments

Comments
 (0)