1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 14:13:18 +08:00

Dispose of Streams when used

This commit is contained in:
Naxesss 2021-10-12 00:13:38 +02:00
parent 01d77fb741
commit 47b4d03145
5 changed files with 10 additions and 6 deletions

View File

@ -83,7 +83,7 @@ namespace osu.Game.Tests.Editing.Checks
private BeatmapVerifierContext getContext(string resourceName, bool allowMissing = false)
{
Stream resourceStream = string.IsNullOrEmpty(resourceName) ? null : TestResources.OpenResource(resourceName);
using Stream resourceStream = string.IsNullOrEmpty(resourceName) ? null : TestResources.OpenResource(resourceName);
if (!allowMissing && resourceStream == null)
throw new FileNotFoundException($"The requested test resource \"{resourceName}\" does not exist.");

View File

@ -104,7 +104,7 @@ namespace osu.Game.Tests.Editing.Checks
private BeatmapVerifierContext getContext(string resourceName, bool allowMissing = false)
{
Stream resourceStream = string.IsNullOrEmpty(resourceName) ? null : TestResources.OpenResource(resourceName);
using Stream resourceStream = string.IsNullOrEmpty(resourceName) ? null : TestResources.OpenResource(resourceName);
if (!allowMissing && resourceStream == null)
throw new FileNotFoundException($"The requested test resource \"{resourceName}\" does not exist.");

View File

@ -50,8 +50,12 @@ namespace osu.Game.Rulesets.Edit.Checks
continue;
}
Stream data = context.WorkingBeatmap.GetStream(storagePath);
StreamFileAbstraction fileAbstraction = new StreamFileAbstraction(filename, data);
StreamFileAbstraction fileAbstraction;
using (Stream data = context.WorkingBeatmap.GetStream(storagePath))
{
fileAbstraction = new StreamFileAbstraction(filename, data);
}
// We use TagLib here for platform invariance; BASS cannot detect audio presence on Linux.
TagLib.File tagFile = null;

View File

@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Edit.Checks
foreach (var file in beatmapSet.Files)
{
Stream data = context.WorkingBeatmap.GetStream(file.FileInfo.StoragePath);
using Stream data = context.WorkingBeatmap.GetStream(file.FileInfo.StoragePath);
if (data == null)
continue;

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Edit.Checks
foreach (var file in beatmapSet.Files)
{
Stream data = context.WorkingBeatmap.GetStream(file.FileInfo.StoragePath);
using Stream data = context.WorkingBeatmap.GetStream(file.FileInfo.StoragePath);
if (data?.Length == 0)
yield return new IssueTemplateZeroBytes(this).Create(file.Filename);
}