Skip to content

Commit 3d5bfc6

Browse files
committed
Refactor loop condition and canvas download logic
Updated the loop condition in `IOManager.cs` to clarify intent when handling locked files. Refactored canvas downloading in `SongFetcher.cs` to ensure `GlobalObjects.Canvas` is cleared after download, improving code clarity and maintainability for both `PauseText` and `ClearAll` options.
1 parent 4dfd020 commit 3d5bfc6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Songify Slim/Util/General/IOManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static async void DownloadCanvas(string canvasUrl, string canvasPath)
125125
if (IsFileLocked(new FileInfo(canvasPath)))
126126
{
127127
Thread.Sleep(1000);
128-
if (i != tries) continue;
128+
if (i < tries) continue;
129129
return;
130130
}
131131

Songify Slim/Util/Songify/SongFetcher.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,11 @@ private static Task WriteSongInfo(TrackInfo songInfo, Enums.RequestPlayerType pl
726726
if (!Settings.Settings.KeepAlbumCover)
727727
{
728728
if (Settings.Settings.DownloadCover && (Settings.Settings.PauseOption == Enums.PauseOptions.PauseText)) IoManager.DownloadCover(null, CoverPath);
729-
if (Settings.Settings.DownloadCanvas && Settings.Settings.PauseOption == Enums.PauseOptions.PauseText) IoManager.DownloadCanvas(null, CanvasPath);
729+
if (Settings.Settings.DownloadCanvas && Settings.Settings.PauseOption == Enums.PauseOptions.PauseText)
730+
{
731+
IoManager.DownloadCanvas(null, CanvasPath);
732+
GlobalObjects.Canvas = null;
733+
}
730734
}
731735
if (Settings.Settings.SplitOutput) IoManager.WriteSplitOutput(Settings.Settings.CustomPauseText, "", "");
732736

@@ -739,7 +743,11 @@ private static Task WriteSongInfo(TrackInfo songInfo, Enums.RequestPlayerType pl
739743
if (!Settings.Settings.KeepAlbumCover)
740744
{
741745
if (Settings.Settings.DownloadCover && Settings.Settings.PauseOption == Enums.PauseOptions.ClearAll) IoManager.DownloadCover(null, CoverPath);
742-
if (Settings.Settings.DownloadCanvas && Settings.Settings.PauseOption == Enums.PauseOptions.PauseText) IoManager.DownloadCanvas(null, CanvasPath);
746+
if (Settings.Settings.DownloadCanvas && Settings.Settings.PauseOption == Enums.PauseOptions.ClearAll)
747+
{
748+
IoManager.DownloadCanvas(null, CanvasPath);
749+
GlobalObjects.Canvas = null;
750+
}
743751
}
744752
IoManager.WriteOutput(SongPath, "");
745753
if (Settings.Settings.SplitOutput) IoManager.WriteSplitOutput("", "", "");

0 commit comments

Comments
 (0)