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); } }
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); }