in src/DependencyManagement/BackgroundDependencySnapshotMaintainer.cs [60:119]
public string InstallAndPurgeSnapshots(Func<PowerShell> pwshFactory, ILogger logger)
{
try
{
if (!_getShouldPerformManagedDependencyUpgrades())
{
logger.Log(
isUserOnlyLog: false,
RpcLog.Types.Level.Warning,
PowerShellWorkerStrings.AutomaticUpgradesAreDisabled);
// Shutdown the timer that calls this method after the EOL date
if (_installAndPurgeTimer is not null)
{
_installAndPurgeTimer.Dispose();
_installAndPurgeTimer = null;
}
return null;
}
// Purge before installing a new snapshot, as we may be able to free some space.
_purger.Purge(logger);
if (IsAnyInstallationStartedRecently())
{
return null;
}
var nextSnapshotPath = _storage.CreateNewSnapshotPath();
using (var pwsh = pwshFactory())
{
_installer.InstallSnapshot(
_dependencyManifest,
nextSnapshotPath,
pwsh,
// Background dependency upgrades are optional because the current
// worker already has a good enough snapshot, and nothing depends on
// the new snapshot yet, so installation failures will not affect
// function invocations.
DependencySnapshotInstallationMode.Optional,
logger);
}
// Now that a new snapshot has been installed, there is a chance an old snapshot can be purged.
_purger.Purge(logger);
return nextSnapshotPath;
}
catch (Exception e)
{
logger.Log(
isUserOnlyLog: false,
RpcLog.Types.Level.Warning,
string.Format(PowerShellWorkerStrings.DependenciesUpgradeSkippedMessage, e.Message));
return null;
}
}