mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
Fix Live game directory being cleaned at instance startup
This commit is contained in:
@@ -247,7 +247,7 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
|
||||
/// <inheritdoc />
|
||||
#pragma warning disable CA1506 // TODO: Decomplexify
|
||||
public async Task CleanUnusedCompileJobs(CompileJob exceptThisOne, CancellationToken cancellationToken)
|
||||
public async Task CleanUnusedCompileJobs(CancellationToken cancellationToken)
|
||||
{
|
||||
List<long> 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
|
||||
}
|
||||
|
||||
@@ -37,11 +37,10 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
Task<IDmbProvider> FromCompileJob(CompileJob compileJob, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all compile jobs that are inactive in the Game folder <paramref name="exceptThisOne"/>
|
||||
/// Deletes all compile jobs that are inactive in the Game folder.
|
||||
/// </summary>
|
||||
/// <param name="exceptThisOne">An optional compile job to not delete</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task CleanUnusedCompileJobs(CompileJob exceptThisOne, CancellationToken cancellationToken);
|
||||
Task CleanUnusedCompileJobs(CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Tgstation.Server.Host.Components.Deployment
|
||||
/// <summary>
|
||||
/// The directory where the <see cref="baseProvider"/> is symlinked to.
|
||||
/// </summary>
|
||||
const string LiveGameDirectory = "Live";
|
||||
public const string LiveGameDirectory = "Live";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DmbName => baseProvider.DmbName;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user