Skip to content

Commit

Permalink
Only keep 1 older version runner around after self-upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
TingluoHuang committed Jan 31, 2024
1 parent 894c500 commit e07fc67
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Runner.Listener/SelfUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class SelfUpdater : RunnerService, ISelfUpdater
private IRunnerServer _runnerServer;
private int _poolId;
private ulong _agentId;
private const int _numberOfOldVersionsToKeep = 1;
private readonly ConcurrentQueue<string> _updateTrace = new();
public bool Busy { get; private set; }

Expand Down Expand Up @@ -509,9 +510,9 @@ private void DeletePreviousVersionRunnerBackup(CancellationToken token)

// delete old bin.2.99.0 folder, only leave the current version and the latest download version
var allBinDirs = Directory.GetDirectories(HostContext.GetDirectory(WellKnownDirectory.Root), "bin.*");
if (allBinDirs.Length > 2)
if (allBinDirs.Length > _numberOfOldVersionsToKeep)
{
// there are more than 2 bin.version folder.
// there are more than one bin.version folder.
// delete older bin.version folders.
foreach (var oldBinDir in allBinDirs)
{
Expand All @@ -538,9 +539,9 @@ private void DeletePreviousVersionRunnerBackup(CancellationToken token)

// delete old externals.2.99.0 folder, only leave the current version and the latest download version
var allExternalsDirs = Directory.GetDirectories(HostContext.GetDirectory(WellKnownDirectory.Root), "externals.*");
if (allExternalsDirs.Length > 2)
if (allExternalsDirs.Length > _numberOfOldVersionsToKeep)
{
// there are more than 2 externals.version folder.
// there are more than one externals.version folder.
// delete older externals.version folders.
foreach (var oldExternalDir in allExternalsDirs)
{
Expand Down

0 comments on commit e07fc67

Please sign in to comment.