示例#1
0
        private void UnzipHelpContent(System.Management.Automation.ExecutionContext context, string srcPath, string destPath)
        {
            if (!Directory.Exists(destPath))
            {
                Directory.CreateDirectory(destPath);
            }
            string directoryName = Path.GetDirectoryName(srcPath);

            if (!directoryName.EndsWith(@"\", StringComparison.Ordinal))
            {
                directoryName = directoryName + @"\";
            }
            if (!destPath.EndsWith(@"\", StringComparison.Ordinal))
            {
                destPath = destPath + @"\";
            }
            if (!CabinetExtractorFactory.GetCabinetExtractor().Extract(Path.GetFileName(srcPath), directoryName, destPath))
            {
                throw new UpdatableHelpSystemException("UnableToExtract", StringUtil.Format(HelpDisplayStrings.UnzipFailure, new object[0]), ErrorCategory.InvalidOperation, null, null);
            }
            foreach (string str2 in Directory.GetFiles(destPath))
            {
                if (System.IO.File.Exists(str2))
                {
                    FileInfo info = new FileInfo(str2);
                    if ((info.Attributes & System.IO.FileAttributes.ReadOnly) == System.IO.FileAttributes.ReadOnly)
                    {
                        info.Attributes &= ~System.IO.FileAttributes.ReadOnly;
                    }
                }
            }
        }
示例#2
0
        public async ValueTask <string> DownloadPdb(string pdbName, Guid signature, uint age, bool skipSymbolServer)
        {
            var key = signature.ToString("N") + age;

            SymbolServerArtifactRetrieverEventSource.Logger.BeginPdbDownload(pdbName, key);

            var canonicalPdbFileName = Path.GetFileName(pdbName); // because sometimes full path is baked in
            var downloadDir          = Path.Combine(this.symbolServerInformation.DownloadLocation, "Symbols", canonicalPdbFileName, key);

            Directory.CreateDirectory(downloadDir);
            var downloadPath = Path.Combine(downloadDir, canonicalPdbFileName);

            // if we had this file on disk somehow and it is a valid pdb, use it.
            if (File.Exists(downloadPath) && IsValidPdb(downloadPath, signature, age))
            {
                SymbolServerArtifactRetrieverEventSource.Logger.EndPdbDownload(pdbName, key);
                return(downloadPath);
            }

            if (skipSymbolServer)
            {
                return(null);
            }

            var fullKey           = $"{canonicalPdbFileName}/{key}/{canonicalPdbFileName}";
            var fullCompressedKey = $"{canonicalPdbFileName}/{key}/{Path.GetFileNameWithoutExtension(canonicalPdbFileName)}.pd_";

            SymbolServerArtifactRetrieverEventSource.Logger.BeginSymbolServerLookups();

            foreach (var symbolServer in this.symbolServerInformation.SymbolServers.OrderBy(t => t.Priority))
            {
                SymbolServerArtifactRetrieverEventSource.Logger.BeginSymbolServerRequest(symbolServer.Url, fullKey);

                // download and verify using the regular mechanism
                if (await this.DownloadPdbFromSymbolServer(symbolServer, fullKey, downloadPath) && IsValidPdb(downloadPath, signature, age))
                {
                    SymbolServerArtifactRetrieverEventSource.Logger.EndSymbolServerRequest(symbolServer.Url, fullKey);
                    SymbolServerArtifactRetrieverEventSource.Logger.EndSymbolServerLookups();
                    SymbolServerArtifactRetrieverEventSource.Logger.EndPdbDownload(pdbName, key);

                    return(downloadPath);
                }

                SymbolServerArtifactRetrieverEventSource.Logger.EndSymbolServerRequest(symbolServer.Url, fullKey);
                SymbolServerArtifactRetrieverEventSource.Logger.BeginSymbolServerRequest(symbolServer.Url, fullCompressedKey);

                // now test the compressed case
                var pdcompressedDownloadPath = Path.Combine(downloadDir, Path.GetFileNameWithoutExtension(canonicalPdbFileName) + ".pd_");

                if (await this.DownloadPdbFromSymbolServer(symbolServer, fullCompressedKey, pdcompressedDownloadPath) &&
                    CabinetExtractorFactory.GetCabinetExtractor().Extract(string.Empty, pdcompressedDownloadPath, downloadDir) &&
                    IsValidPdb(downloadPath, signature, age))
                {
                    SymbolServerArtifactRetrieverEventSource.Logger.EndSymbolServerRequest(symbolServer.Url, fullCompressedKey);
                    SymbolServerArtifactRetrieverEventSource.Logger.EndSymbolServerLookups();
                    SymbolServerArtifactRetrieverEventSource.Logger.EndPdbDownload(pdbName, key);
                    return(downloadPath);
                }

                SymbolServerArtifactRetrieverEventSource.Logger.EndSymbolServerRequest(symbolServer.Url, fullCompressedKey);
            }

            SymbolServerArtifactRetrieverEventSource.Logger.EndSymbolServerLookups();
            SymbolServerArtifactRetrieverEventSource.Logger.EndPdbDownload(pdbName, key);

            return(null);
        }