@page "/Settings/Tools" @using Hangfire @using LANCommander.Helpers @using LANCommander.Server.Jobs.Background @using LANCommander.Server.Services.Exceptions @using ZiggyCreatures.Caching.Fusion @inject ArchiveService ArchiveService @inject PageService PageService @inject UpdateService UpdateService @inject StorageLocationService StorageLocationService @inject IMessageService MessageService @inject IFusionCache FusionCache @inject ILogger Logger @attribute [Authorize(Roles = RoleService.AdministratorRoleName)]

Recalculate File Sizes

Some file sizes are cached in the database. Click the button below to scan through all files and recalculate their size.

Clear Cache

A cached list of games is sent to the clients on import. Click the button below to bust this cache if you don't see your changes.

Download Clients

Check for any client releases for the current version and download them to this server.

Missing Archives

List and fix all archives that are missing their backing files.

View Missing Archives

Orphaned Files

Find and delete any files that don't exist in the database and may be taking up unnecessary disk space.

View Orphaned Files

Active Sessions

List and delete any active user play sessions.

View Active Sessions

Regenerate Page Routes

Fix any page routes that seem to be out of date or corrupt.

Regenerate Thumbnails

Clear out the existing thumbnail cache and generate replacements.

@code { bool RecalculatingFileSizes = false; bool DownloadingLaunchers = false; bool FixingPageRoutes = false; bool RegeneratingThumbnails = false; async Task RecalculateFileSizes() { RecalculatingFileSizes = true; await Task.Yield(); await InvokeAsync(StateHasChanged); var archives = await ArchiveService.AsNoTracking().GetAsync(); var results = new List(); foreach (var archive in archives) { var result = await ArchiveService.RecalculateFileSizeArchiveAsync(archive); results.Add(result); } if (results.All(x => x)) MessageService.Success("File sizes recalculated!"); else MessageService.Warning("File sizes recalculated but some failed!"); RecalculatingFileSizes = false; await Task.Yield(); await InvokeAsync(StateHasChanged); } async Task ClearCache() { await FusionCache.RemoveByTagAsync("Games"); await FusionCache.RemoveByTagAsync("Depot"); await FusionCache.RemoveByTagAsync("Library"); await FusionCache.RemoveByTagAsync("Archives"); MessageService.Success("Cache cleared!"); } async Task DownloadLaunchers() { DownloadingLaunchers = true; await Task.Yield(); await InvokeAsync(StateHasChanged); try { await UpdateService.DownloadLatestLauncherReleaseAsync(); MessageService.Success("Launchers downloaded!"); } catch (ReleaseNotFoundException ex) { MessageService.Error($"Launchers could not be downloaded, unknown release {ex.Version}"); } catch (Exception ex) { Logger?.LogError(ex, "An unknown error occurred while trying to download launchers"); MessageService.Error("An unknown error occurred"); } DownloadingLaunchers = false; await Task.Yield(); await InvokeAsync(StateHasChanged); } async Task FixPageRoutes() { FixingPageRoutes = true; await Task.Yield(); await InvokeAsync(StateHasChanged); try { await PageService.FixRoutesAsync(); MessageService.Success("Routes fixed!"); } catch (Exception ex) { MessageService.Error("Could not fix all routes!"); } FixingPageRoutes = false; await Task.Yield(); await InvokeAsync(StateHasChanged); } async Task RegenerateThumbnails() { RegeneratingThumbnails = true; await Task.Yield(); await InvokeAsync(StateHasChanged); var storageLocations = await StorageLocationService.GetAsync(); foreach (var storageLocation in storageLocations.Where(l => l.Type == SDK.Enums.StorageLocationType.Media)) { var thumbnailFiles = Directory.GetFiles(storageLocation.Path).Where(f => f.EndsWith(".Thumb")); foreach (var thumbnailFile in thumbnailFiles) FileHelpers.DeleteIfExists(thumbnailFile); } BackgroundJob.Enqueue(x => x.ExecuteAsync()); RegeneratingThumbnails = false; await Task.Yield(); await InvokeAsync(StateHasChanged); MessageService.Success("Cache has been cleared and is being regenerated in the background"); } }