Beispiel #1
0
        /// <summary>
        /// Generic method to find a hash inside a collection of IndexFiles
        /// </summary>
        /// <param name="indices"></param>
        /// <param name="path"></param>
        /// <param name="hash"></param>
        /// <param name="indexEntry">The IndexFile containing the hash</param>
        /// <returns>Returns the path to the blob file</returns>
        private string GetIndexEntryAndPath(IEnumerable <IndexFile> indices, string path, MD5Hash hash, out IndexEntry indexEntry)
        {
            indexEntry = null;

            foreach (var index in indices)
            {
                if (!index.IsGroupIndex && index.TryGet(hash, out indexEntry))
                {
                    // blob file location
                    string blobpath = Helpers.GetCDNPath(index.Checksum.ToString(), path, _sourceDirectory);
                    if (File.Exists(blobpath))
                    {
                        return(blobpath);
                    }

                    return(null);
                }
            }

            return(null);
        }