From 7f28d0b63d3eeb0db27dcf9f718771bc7edba165 Mon Sep 17 00:00:00 2001 From: Awbugl Date: Fri, 29 Apr 2022 18:03:46 +0800 Subject: [PATCH] Fix Bug --- Model/ArcaeaChart.cs | 36 +++++++++++++----------------------- Path.cs | 2 +- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/Model/ArcaeaChart.cs b/Model/ArcaeaChart.cs index 69bcd93..d0ee12e 100644 --- a/Model/ArcaeaChart.cs +++ b/Model/ArcaeaChart.cs @@ -39,8 +39,6 @@ public class ArcaeaChart internal DifficultyInfo DifficultyInfo => DifficultyInfo.GetByIndex(RatingClass); - internal string ConstString => $"[{DifficultyInfo.ShortStr} {Const:0.0}]"; - internal string GetSongName(byte length) => NameEn.Length < length + 3 ? NameEn @@ -50,28 +48,20 @@ internal async Task GetSongImage() { var path = Path.ArcaeaSong(this); - try + if (!SongImage.TryGetValue(path, out var stream)) { - if (!SongImage.TryGetValue(path, out var stream)) - { - await using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); - var bytes = new byte[fileStream.Length]; - fileStream.Read(bytes, 0, bytes.Length); - fileStream.Close(); - stream = new MemoryStream(bytes); - SongImage.Add(path, stream); - } - - var img = new Image(stream); - if (img.Width == 512) return img; - var newimg = new Image(img, 512, 512); - img.Dispose(); - return newimg; - } - catch - { - File.Delete(path); - throw new ArgumentException($"InvalidSongImage: {NameEn}, deleted."); + await using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); + var bytes = new byte[fileStream.Length]; + fileStream.Read(bytes, 0, bytes.Length); + fileStream.Close(); + stream = new MemoryStream(bytes); + SongImage.Add(path, stream); } + + var img = new Image(stream); + if (img.Width == 512) return img; + var newimg = new Image(img, 512, 512); + img.Dispose(); + return newimg; } } diff --git a/Path.cs b/Path.cs index 126684c..a9b2f9d 100644 --- a/Path.cs +++ b/Path.cs @@ -69,7 +69,7 @@ internal static Path ArcaeaBg3(string sid, sbyte difficulty) => internal static Path ArcaeaBg3Mask(int side) => new(_arcaeaSourceRoot + $"RawV3Bg_{side}.png"); internal static string ArcaeaSong(ArcaeaChart chart) => - $"{_songPath}/{(chart.RemoteDownload ? "dl_" : "")}/{(chart.JacketOverride ? chart.RatingClass.ToString() : "base")}.jpg"; + $"{_songPath}/{(chart.RemoteDownload ? "dl_" : "")}{chart.SongID}/{(chart.JacketOverride ? chart.RatingClass.ToString() : "base")}.jpg"; internal static Path ArcaeaRating(short potential) {