Skip to content

Commit

Permalink
Fix Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Awbugl committed Apr 29, 2022
1 parent 7352f8f commit 7f28d0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
36 changes: 13 additions & 23 deletions Model/ArcaeaChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,28 +48,20 @@ internal async Task<Image> 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;
}
}
2 changes: 1 addition & 1 deletion Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 7f28d0b

Please sign in to comment.