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

Properly dispose of Stream in bg quality check

This commit is contained in:
Naxesss 2021-11-10 05:06:11 +01:00
parent 5dc6a9ed21
commit b888185799

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using osu.Game.Rulesets.Edit.Checks.Components; using osu.Game.Rulesets.Edit.Checks.Components;
namespace osu.Game.Rulesets.Edit.Checks namespace osu.Game.Rulesets.Edit.Checks
@ -48,11 +49,15 @@ namespace osu.Game.Rulesets.Edit.Checks
yield return new IssueTemplateLowResolution(this).Create(texture.Width, texture.Height); yield return new IssueTemplateLowResolution(this).Create(texture.Width, texture.Height);
string storagePath = context.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile); string storagePath = context.Beatmap.BeatmapInfo.BeatmapSet.GetPathForFile(backgroundFile);
double filesizeMb = context.WorkingBeatmap.GetStream(storagePath).Length / (1024d * 1024d);
using (Stream stream = context.WorkingBeatmap.GetStream(storagePath))
{
double filesizeMb = stream.Length / (1024d * 1024d);
if (filesizeMb > max_filesize_mb) if (filesizeMb > max_filesize_mb)
yield return new IssueTemplateTooUncompressed(this).Create(filesizeMb); yield return new IssueTemplateTooUncompressed(this).Create(filesizeMb);
} }
}
public class IssueTemplateTooHighResolution : IssueTemplate public class IssueTemplateTooHighResolution : IssueTemplate
{ {