예제 #1
0
        public void StoreEntryWithSha(string sha, string filename)
        {
            if (!Enabled || ContainsEntryWithSha(sha))
            {
                return;
            }

            EnsureCacheDirectory();
            using (var locker = new FileLocker(Path.Combine(cacheLocation, lockFileName)))
            {
                FileCopier.Copy(filename, Path.Combine(cacheLocation, sha), true);
                internalCache.Add(sha);
            }
        }
예제 #2
0
 private void Populate()
 {
     if (!Enabled)
     {
         return;
     }
     EnsureCacheDirectory();
     using (var locker = new FileLocker(Path.Combine(cacheLocation, lockFileName)))
     {
         var dinfo = new DirectoryInfo(cacheLocation);
         foreach (var file in dinfo.EnumerateFiles())
         {
             internalCache.Add(file.Name);
         }
     }
 }
        private bool TryFetchFromCacheOrUriInner(Uri uri, out string fileName)
        {
            using (var locker = new FileLocker(GetCacheIndexLockLocation()))
            {
                if (TryGetFromCache(uri, out fileName))
                {
                    fetchedFiles.Add(fileName, uri);
                    return(true);
                }

                if (TryFetchFromUriInner(uri, out fileName))
                {
                    UpdateInCache(uri, fileName);
                    return(true);
                }
            }

            fileName = null;
            return(false);
        }