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();
        }
    public IEnumerator Test003_ChangesGetStartPageToken()
    {
        var request = GoogleDriveChanges.GetStartPageToken();

        yield return(request.Send());

        Assert.IsFalse(request.IsError);
        changesToken = request.ResponseData.StartPageTokenValue;
        Assert.IsFalse(string.IsNullOrEmpty(changesToken));
    }
    public IEnumerator Test999_ChangesList()
    {
        var request = GoogleDriveChanges.List(changesToken);

        yield return(request.Send());

        Assert.IsFalse(request.IsError);
        Assert.IsTrue(request.ResponseData.Changes != null && request.ResponseData.Changes.Count > 0);
        Assert.IsTrue(request.ResponseData.Changes.Exists(c => c.FileId == createdFileId));
        Assert.IsTrue(request.ResponseData.Changes.Exists(c => c.FileId == copiedFileId));
        Assert.IsTrue(request.ResponseData.Changes.Find(c => c.FileId == createdFileId).Removed);
        Assert.IsTrue(request.ResponseData.Changes.Find(c => c.FileId == createdFileId).Removed);
    }
        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.");
        }