Example #1
0
        private async Task <string> SearchSymbolServerForFile(string fileSimpleName, string fileIndexPath, Func <string, bool> match)
        {
            var tasks = new List <Task <string> >();

            foreach (var element in SymPathElement.GetElements(SymbolPath))
            {
                if (element.IsSymServer)
                {
                    tasks.Add(TryGetFileFromServerAsync(element.Target, fileIndexPath, element.Cache ?? SymbolCache));
                }
                else
                {
                    string fullDestPath = Path.Combine(element.Cache ?? SymbolCache, fileIndexPath);
                    string sourcePath   = Path.Combine(element.Target, fileSimpleName);
                    tasks.Add(CheckAndCopyRemoteFile(sourcePath, fullDestPath, match));
                }
            }

            string result = await tasks.GetFirstNonNullResult();

            return(result);
        }
Example #2
0
        /// <summary>
        /// Default implementation of finding a pdb.
        /// </summary>
        /// <param name="pdbName">The name the pdb is indexed under.</param>
        /// <param name="pdbIndexGuid">The guid the pdb is indexed under.</param>
        /// <param name="pdbIndexAge">The age of the pdb.</param>
        /// <returns>A full path on disk (local) of where the pdb was copied to.</returns>
        public override string FindPdb(string pdbName, Guid pdbIndexGuid, int pdbIndexAge)
        {
            if (string.IsNullOrEmpty(pdbName))
            {
                return(null);
            }

            string pdbSimpleName = Path.GetFileName(pdbName);

            if (pdbName != pdbSimpleName)
            {
                if (ValidatePdb(pdbName, pdbIndexGuid, pdbIndexAge))
                {
                    return(pdbName);
                }
            }

            // Check to see if it's already cached.
            PdbEntry entry  = new PdbEntry(pdbSimpleName, pdbIndexGuid, pdbIndexAge);
            string   result = GetPdbEntry(entry);

            if (result != null)
            {
                return(result);
            }

            HashSet <PdbEntry> missingPdbs = _missingPdbs;

            if (IsMissing(missingPdbs, entry))
            {
                return(null);
            }

            string pdbIndexPath = GetIndexPath(pdbSimpleName, pdbIndexGuid, pdbIndexAge);

            foreach (SymPathElement element in SymPathElement.GetElements(SymbolPath))
            {
                if (element.IsSymServer)
                {
                    string targetPath = TryGetFileFromServer(element.Target, pdbIndexPath, element.Cache ?? SymbolCache);
                    if (targetPath != null)
                    {
                        Trace("Found pdb {0} from server '{1}' on path '{2}'.  Copied to '{3}'.", pdbSimpleName, element.Target, pdbIndexPath, targetPath);
                        SetPdbEntry(missingPdbs, entry, targetPath);
                        return(targetPath);
                    }

                    Trace("No matching pdb found on server '{0}' on path '{1}'.", element.Target, pdbIndexPath);
                }
                else
                {
                    string fullPath = Path.Combine(element.Target, pdbSimpleName);
                    if (ValidatePdb(fullPath, pdbIndexGuid, pdbIndexAge))
                    {
                        Trace($"Found pdb '{pdbSimpleName}' at '{fullPath}'.");
                        SetPdbEntry(missingPdbs, entry, fullPath);
                        return(fullPath);
                    }

                    Trace($"Mismatched pdb found at '{fullPath}'.");
                }
            }

            SetPdbEntry(missingPdbs, entry, null);
            return(null);
        }
Example #3
0
        /// <summary>
        /// Attempts to locate a binary via the symbol server.  This function will then copy the file
        /// locally to the symbol cache and return the location of the local file on disk.
        /// </summary>
        /// <param name="fileName">The filename that the binary is indexed under.</param>
        /// <param name="buildTimeStamp">The build timestamp the binary is indexed under.</param>
        /// <param name="imageSize">The image size the binary is indexed under.</param>
        /// <param name="checkProperties">Whether or not to validate the properties of the binary after download.</param>
        /// <returns>A full path on disk (local) of where the binary was copied to, null if it was not found.</returns>
        public override string FindBinary(string fileName, int buildTimeStamp, int imageSize, bool checkProperties = true)
        {
            string fullPath = fileName;

            fileName = Path.GetFileName(fullPath).ToLower();

            // First see if we already have the result cached.
            FileEntry entry  = new FileEntry(fileName, buildTimeStamp, imageSize);
            string    result = GetFileEntry(entry);

            if (result != null)
            {
                return(result);
            }

            HashSet <FileEntry> missingFiles = _missingFiles;

            if (IsMissing(missingFiles, entry))
            {
                return(null);
            }

            // Test to see if the file is on disk.
            if (ValidateBinary(fullPath, buildTimeStamp, imageSize, checkProperties))
            {
                SetFileEntry(missingFiles, entry, fullPath);
                return(fullPath);
            }

            // Finally, check the symbol paths.
            string exeIndexPath = null;

            foreach (SymPathElement element in SymPathElement.GetElements(SymbolPath))
            {
                if (element.IsSymServer)
                {
                    if (exeIndexPath == null)
                    {
                        exeIndexPath = GetIndexPath(fileName, buildTimeStamp, imageSize);
                    }

                    string target = TryGetFileFromServer(element.Target, exeIndexPath, element.Cache ?? SymbolCache);
                    if (target == null)
                    {
                        Trace($"Server '{element.Target}' did not have file '{Path.GetFileName(fileName)}' with timestamp={buildTimeStamp:x} and filesize={imageSize:x}.");
                    }
                    else if (ValidateBinary(target, buildTimeStamp, imageSize, checkProperties))
                    {
                        Trace($"Found '{fileName}' on server '{element.Target}'.  Copied to '{target}'.");
                        SetFileEntry(missingFiles, entry, target);
                        return(target);
                    }
                }
                else
                {
                    string filePath = Path.Combine(element.Target, fileName);
                    if (ValidateBinary(filePath, buildTimeStamp, imageSize, checkProperties))
                    {
                        Trace($"Found '{fileName}' at '{filePath}'.");
                        SetFileEntry(missingFiles, entry, filePath);
                        return(filePath);
                    }
                }
            }

            SetFileEntry(missingFiles, entry, null);
            return(null);
        }