public string GetPathWithAcceptableDependencyVersionsInstalled() { var lastSnapshotPath = _storage.GetLatestInstalledSnapshot(); if (lastSnapshotPath == null) { _logger.Log(isUserOnlyLog: false, Level.Information, string.Format(PowerShellWorkerStrings.NoInstalledDependencySnapshot, lastSnapshotPath)); return(null); } _logger.Log(isUserOnlyLog: false, Level.Information, string.Format(PowerShellWorkerStrings.LastInstalledDependencySnapshotFound, lastSnapshotPath)); if (_storage.IsEquivalentDependencyManifest(lastSnapshotPath)) { _logger.Log(isUserOnlyLog: false, Level.Information, string.Format(PowerShellWorkerStrings.EquivalentDependencySnapshotManifest, lastSnapshotPath)); return(lastSnapshotPath); } var dependencies = _storage.GetDependencies(); if (dependencies.All(entry => IsAcceptableVersionInstalled(lastSnapshotPath, entry))) { _logger.Log(isUserOnlyLog: false, Level.Information, string.Format(PowerShellWorkerStrings.DependencySnapshotContainsAcceptableModuleVersions, lastSnapshotPath)); return(lastSnapshotPath); } _logger.Log(isUserOnlyLog: false, Level.Information, string.Format(PowerShellWorkerStrings.DependencySnapshotDoesNotContainAcceptableModuleVersions, lastSnapshotPath)); return(null); }
private void PromoteToInstalledOrRemove( string installingPath, string installedPath, DependencySnapshotInstallationMode installationMode, ILogger logger) { var latestSnapshot = _storage.GetLatestInstalledSnapshot(); if (latestSnapshot != null && _snapshotComparer.AreEquivalent(installingPath, latestSnapshot, logger)) { logger.Log( isUserOnlyLog: false, LogLevel.Trace, string.Format(PowerShellWorkerStrings.RemovingEquivalentDependencySnapshot, installingPath, latestSnapshot)); // The new snapshot is not better than the latest installed snapshot, // so remove the new snapshot and update the timestamp of the latest snapshot // in order to avoid unnecessary worker restarts. _storage.RemoveSnapshot(installingPath); _storage.SetSnapshotCreationTimeToUtcNow(latestSnapshot); } else { PromoteToInstalled(installingPath, installedPath, installationMode, logger); } }
internal void CheckForNewerDependencySnapshot(string currentlyUsedSnapshot, ILogger logger) { logger.Log( isUserOnlyLog: false, LogLevel.Trace, string.Format(PowerShellWorkerStrings.LookingForNewerDependencySnapshot, currentlyUsedSnapshot)); var latestInstalledSnapshot = _storage.GetLatestInstalledSnapshot(); if (latestInstalledSnapshot == null || string.CompareOrdinal(latestInstalledSnapshot, currentlyUsedSnapshot) <= 0) { logger.Log( isUserOnlyLog: false, LogLevel.Trace, string.Format(PowerShellWorkerStrings.NoNewerDependencySnapshotDetected)); } else { logger.Log( isUserOnlyLog: false, LogLevel.Trace, string.Format(PowerShellWorkerStrings.NewerDependencySnapshotDetected, latestInstalledSnapshot)); _workerRestarter.Restart(logger); } }
public string GetPathWithAcceptableDependencyVersionsInstalled() { var lastSnapshotPath = _storage.GetLatestInstalledSnapshot(); if (lastSnapshotPath != null) { var dependencies = _storage.GetDependencies(); if (dependencies.All(entry => IsAcceptableVersionInstalled(lastSnapshotPath, entry))) { return(lastSnapshotPath); } } return(null); }