diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs index a157d75e30..62a03990dd 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs @@ -247,7 +247,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// #pragma warning disable CA1506 // TODO: Decomplexify - public async Task CleanUnusedCompileJobs(CompileJob exceptThisOne, CancellationToken cancellationToken) + public async Task CleanUnusedCompileJobs(CancellationToken cancellationToken) { List jobIdsToSkip; @@ -265,13 +265,11 @@ namespace Tgstation.Server.Host.Components.Deployment .Select(x => x.DirectoryName.Value) .ToListAsync(cancellationToken) .ConfigureAwait(false)) - .Select(x => x.ToString().ToUpperInvariant()) + .Select(x => x.ToString()) .ToList(); }).ConfigureAwait(false); - // add the other exemption - if (exceptThisOne != null) - jobUidsToNotErase.Add(exceptThisOne.DirectoryName.Value.ToString().ToUpperInvariant()); + jobUidsToNotErase.Add(WindowsSwappableDmbProvider.LiveGameDirectory); logger.LogTrace("We will not clean the following directories: {0}", String.Join(", ", jobUidsToNotErase)); @@ -283,8 +281,9 @@ namespace Tgstation.Server.Host.Components.Deployment var tasks = directories.Select(async x => { var nameOnly = ioManager.GetFileName(x); - if (jobUidsToNotErase.Contains(nameOnly.ToUpperInvariant())) + if (jobUidsToNotErase.Contains(nameOnly)) return; + logger.LogDebug("Cleaning unused game folder: {0}...", nameOnly); try { ++deleting; @@ -300,10 +299,7 @@ namespace Tgstation.Server.Host.Components.Deployment } }).ToList(); if (deleting > 0) - { - logger.LogDebug("Cleaning unused game folders: {0}...", String.Join(", ", directories)); await Task.WhenAll(tasks).ConfigureAwait(false); - } } #pragma warning restore CA1506 } diff --git a/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs index 266f3b41e8..4f5059c2be 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs @@ -37,11 +37,10 @@ namespace Tgstation.Server.Host.Components.Deployment Task FromCompileJob(CompileJob compileJob, CancellationToken cancellationToken); /// - /// Deletes all compile jobs that are inactive in the Game folder + /// Deletes all compile jobs that are inactive in the Game folder. /// - /// An optional compile job to not delete /// The for the operation /// A representing the running operation - Task CleanUnusedCompileJobs(CompileJob exceptThisOne, CancellationToken cancellationToken); + Task CleanUnusedCompileJobs(CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Deployment/WindowsSwappableDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/WindowsSwappableDmbProvider.cs index add8f65690..597333c54c 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/WindowsSwappableDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/WindowsSwappableDmbProvider.cs @@ -14,7 +14,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// /// The directory where the is symlinked to. /// - const string LiveGameDirectory = "Live"; + public const string LiveGameDirectory = "Live"; /// public string DmbName => baseProvider.DmbName; diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 0e23c4cca1..87814d36c6 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -15,7 +15,6 @@ using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Components.Watchdog; using Tgstation.Server.Host.Core; using Tgstation.Server.Host.Database; -using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; @@ -623,12 +622,7 @@ namespace Tgstation.Server.Host.Components // dependent on so many things, its just safer this way await Watchdog.StartAsync(cancellationToken).ConfigureAwait(false); - CompileJob latestCompileJob = null; - await databaseContextFactory.UseContext(async db => - { - latestCompileJob = await db.MostRecentCompletedCompileJobOrDefault(metadata, cancellationToken).ConfigureAwait(false); - }).ConfigureAwait(false); - await dmbFactory.CleanUnusedCompileJobs(latestCompileJob, cancellationToken).ConfigureAwait(false); + await dmbFactory.CleanUnusedCompileJobs(cancellationToken).ConfigureAwait(false); } ///