Ejemplo n.º 1
0
        public bool AreEquivalent(string snapshotPathA, string snapshotPathB, ILogger logger)
        {
            try
            {
                var versionSubdirsA = PowerShellModuleSnapshotTools.GetModuleVersionSubdirectories(snapshotPathA, _getSubdirectories);
                var versionSubdirsB = PowerShellModuleSnapshotTools.GetModuleVersionSubdirectories(snapshotPathB, _getSubdirectories);
                return(versionSubdirsA.SequenceEqual(versionSubdirsB));
            }
            catch (IOException e)
            {
                // An exception here is not really expected, so logging it just in case,
                // but it is safe to assume that the snapshots are different.
                var message = string.Format(
                    PowerShellWorkerStrings.FailedToCompareDependencySnapshots,
                    snapshotPathA,
                    snapshotPathB,
                    e.Message);

                logger.Log(isUserOnlyLog: false, LogLevel.Warning, message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public void LogDependencySnapshotContent(string snapshotPath, ILogger logger)
        {
            try
            {
                var moduleVersionSubdirectories = PowerShellModuleSnapshotTools.GetModuleVersionSubdirectories(snapshotPath);

                foreach (var moduleVersionSubdirectory in moduleVersionSubdirectories)
                {
                    // Module version subdirectories follow the following pattern: <snapshotPath>\<module name>\<module version>
                    var moduleName    = Path.GetFileName(Path.GetDirectoryName(moduleVersionSubdirectory));
                    var moduleVersion = Path.GetFileName(moduleVersionSubdirectory);
                    var snapshotName  = Path.GetFileName(snapshotPath);

                    var message = string.Format(PowerShellWorkerStrings.DependencyShapshotContent, snapshotName, moduleName, moduleVersion);
                    logger.Log(isUserOnlyLog: false, LogLevel.Trace, message);
                }
            }
            catch (Exception e) when(e is IOException || e is UnauthorizedAccessException)
            {
                var message = string.Format(PowerShellWorkerStrings.FailedToEnumerateDependencySnapshotContent, snapshotPath, e.Message);

                logger.Log(isUserOnlyLog: false, LogLevel.Warning, message);
            }
        }