private async Task ProcessChangesListAsync(CacheManifest manifest) { var changeList = await GoogleDriveChanges.List(manifest.StartToken).Send(); foreach (var change in changeList.Changes) { if (!manifest.ContainsKey(change.FileId)) { continue; } var filePath = string.Concat(CacheDirPath, "/", manifest[change.FileId]); if (File.Exists(filePath)) { File.Delete(filePath); LogMessage($"File '{filePath}' has been changed; cached version has been purged."); } } if (!string.IsNullOrWhiteSpace(changeList.NextPageToken)) { manifest.StartToken = changeList.NextPageToken; await ProcessChangesListAsync(manifest); } IOUtils.WebGLSyncFs(); }
private void LoadCacheManifests() { foreach (var filePath in Directory.GetFiles(_cachePath, "*." + CacheManifest.FILE_EXTENSION)) { var cacheManifest = new CacheManifest(filePath); cacheManifest.Load(); var fetcherName = Path.GetFileNameWithoutExtension(filePath); _cacheManifestByFetcherName.Add(fetcherName, new CacheManifest(filePath)); } }
public static async Task <CacheManifest> ReadOrCreateAsync() { if (!File.Exists(filePath)) { var manifest = new CacheManifest(); await IOUtils.WriteTextFileAsync(filePath, JsonUtility.ToJson(manifest)); return(manifest); } var manifestJson = await IOUtils.ReadTextFileAsync(filePath); return(JsonUtility.FromJson <CacheManifest>(manifestJson)); }
/// <summary> /// method to initiate Prefetch processing based on provided manifest uri. /// </summary> /// <param name="manifestUri"></param> public static void InitiatePrefetch(string manifestUri) { // if cache is not supported then don't bother prefetching. if (Device.NetworkGetMethod == MonoCross.Utilities.Network.NetworkGetMethod.NoCache) { Device.Log.Debug("Cache is not supported, prefetch request ignored."); return; } CacheManifest cacheManifest = CacheManifest.CreateFromUri(manifestUri); CacheIndexMap.Add(cacheManifest); Device.Thread.QueueIdle(CacheIndexMap.PreFetchIndexes); Device.Thread.QueueIdle(CacheIndexMap.CleanIndexes); }
protected CombinedFileCollection(string target, HtmlHelper helper, UrlHelper urlHelper, bool combine, int version, CacheManifest cache) { if (cache != null) { Version = -1; } else { Version = version; } _urlHelper = urlHelper; _combine = combine; _cache = cache; _context = helper.ViewContext.HttpContext; _target = _urlHelper.Content(target); _targetFile = _context.Server.MapPath(_target); }
protected CombinedFileCollection(string target, HtmlHelper helper, UrlHelper urlHelper, bool combine, int version, CacheManifest cache) { if (cache!=null) { Version = -1; } else { Version = version; } _urlHelper = urlHelper; _combine = combine; _cache = cache; _context = helper.ViewContext.HttpContext; _target = _urlHelper.Content(target); _targetFile = _context.Server.MapPath(_target); }
private async Task RunSmartCachingScanAsync() { smartCachingScanPending = false; var startTime = DateTime.Now; var manifest = await CacheManifest.ReadOrCreateAsync(); LogMessage("Running smart caching scan..."); if (!string.IsNullOrEmpty(manifest.StartToken)) { await ProcessChangesListAsync(manifest); } var newStartToken = (await GoogleDriveChanges.GetStartPageToken().Send()).StartPageTokenValue; manifest.StartToken = newStartToken; await manifest.WriteAsync(); LogMessage($"Updated smart cache changes token: {newStartToken}"); LogMessage($"Finished smart caching scan in {(DateTime.Now - startTime).TotalSeconds:0.###} seconds."); }
public CacheActionResult(CacheManifest mainfest) { _mainfest = mainfest; }
public static Dictionary <int, T> GetCache(object owner) => CacheManifest.GetOrCreateValue(owner);