Skip to content

Commit

Permalink
cleanup error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
N00MKRAD committed Oct 21, 2020
1 parent eb8036a commit 068f362
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
3 changes: 1 addition & 2 deletions Code/Main/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ public void AfterFirstUpscale ()

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
try { Program.Cleanup(); }
catch { } // This is fine if it fails due to locks, runs on startup anyway.
Program.Cleanup();
}

public void SetHasPreview (bool state)
Expand Down
27 changes: 17 additions & 10 deletions Code/Main/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,23 @@ public static MsgBox ShowMessage (string msg, string title = "Message")

public static void Cleanup ()
{
IOUtils.ClearDir(Paths.previewPath);
IOUtils.ClearDir(Paths.previewOutPath);
IOUtils.ClearDir(Paths.clipboardFolderPath);
IOUtils.ClearDir(Paths.imgInPath);
IOUtils.ClearDir(Paths.imgOutPath);
IOUtils.ClearDir(Paths.imgOutNcnnPath);
IOUtils.ClearDir(Paths.tempImgPath.GetParentDir());
IOUtils.ClearDir(Path.Combine(IOUtils.GetAppDataDir(), "giftemp"));
IOUtils.DeleteIfExists(Path.Combine(Paths.presetsPath, "lastUsed"));
IOUtils.ClearDir(Paths.compositionOut);
try
{
IOUtils.ClearDir(Paths.previewPath);
IOUtils.ClearDir(Paths.previewOutPath);
IOUtils.ClearDir(Paths.clipboardFolderPath);
IOUtils.ClearDir(Paths.imgInPath);
IOUtils.ClearDir(Paths.imgOutPath);
IOUtils.ClearDir(Paths.imgOutNcnnPath);
IOUtils.ClearDir(Paths.tempImgPath.GetParentDir());
IOUtils.ClearDir(Path.Combine(IOUtils.GetAppDataDir(), "giftemp"));
IOUtils.DeleteIfExists(Path.Combine(Paths.presetsPath, "lastUsed"));
IOUtils.ClearDir(Paths.compositionOut);
}
catch (Exception e)
{
Logger.Log("Error during cleanup: " + e.Message);
}
}

public static void CloseTempForms ()
Expand Down

0 comments on commit 068f362

Please sign in to comment.