Skip to content

Commit

Permalink
Tmp directory cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorixon committed Sep 10, 2023
1 parent f9f25d6 commit 5263dd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GIMI-ModManager.Core/Services/SkinManagerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public async Task<string> GetCurrentSwapVariationAsync(Guid characterSkinEntryId

public void Dispose()
{
_userIniWatcher.Dispose();
_userIniWatcher?.Dispose();
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/GIMI-ModManager.WinUI/Services/ActivationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public async Task ActivateAsync(object activationArgs)
// Activate the MainWindow.
App.MainWindow.Activate();

// Set MainWindow Cleanup on Close.
App.MainWindow.Closed += (_, _) => OnApplicationExit();

// Execute tasks after activation.
await StartupAsync();
}
Expand Down Expand Up @@ -172,4 +175,16 @@ private void ScreenSizeSavingTimer_Tick(object sender, object e)
.SaveSettingAsync(ScreenSize.Key, new ScreenSize(width, height) { IsFullScreen = isFullScreen }));
_timer?.Stop();
}


private void OnApplicationExit()
{
_logger.Debug("JASM shutting down...");
_updateChecker.Dispose();
var tmpDir = new DirectoryInfo(App.TMP_DIR);
if (!tmpDir.Exists) return;

_logger.Debug("Deleting temporary directory: {Path}", tmpDir.FullName);
tmpDir.Delete(true);
}
}

0 comments on commit 5263dd0

Please sign in to comment.