async Task GetManifests(CancellationToken token) { var time = DateTime.Now; var start = time; var manifests = await m_Client.GetSyncManifestsAsync(); // TODO Cancellation Token m_GettingSourcesTime = GetElapsedTime(ref time); foreach (var manifest in manifests) { token.ThrowIfCancellationRequested(); // Parse SyncManifest var newManifest = manifest; m_Manifests.TryGetValue(manifest.SourceId, out var oldManifest); // Update the hash cache before sending events m_Manifests[manifest.SourceId] = newManifest.Content.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); if (oldManifest != null) { ComputeDiff(oldManifest, newManifest.Content, out var addedEntries, out var modifiedEntries, out var removedEntries); foreach (var manifestEntry in addedEntries) { token.ThrowIfCancellationRequested(); var reference = new StreamAsset(manifest.SourceId, manifestEntry.key, manifestEntry.entry.Hash, manifestEntry.entry.BoundingBox); m_PendingAdded.Enqueue(reference); } foreach (var manifestEntry in modifiedEntries) { token.ThrowIfCancellationRequested(); var key = manifestEntry.key; var reference = new StreamAsset(manifest.SourceId, key, manifestEntry.entry.Hash, manifestEntry.entry.BoundingBox); m_PendingModified.Enqueue(reference); } foreach (var manifestEntry in removedEntries) { token.ThrowIfCancellationRequested(); var reference = new StreamAsset(manifest.SourceId, manifestEntry.key, manifestEntry.entry.Hash, manifestEntry.entry.BoundingBox); m_PendingRemoved.Enqueue(reference); } } else { foreach (var manifestEntry in manifest.Content) { token.ThrowIfCancellationRequested(); if (!manifestEntry.Key.IsKeyFor <SyncObjectInstance>()) { continue; } var reference = new StreamAsset(manifest.SourceId, manifestEntry.Key, manifestEntry.Value.Hash, manifestEntry.Value.BoundingBox); m_PendingAdded.Enqueue(reference); } } } m_CompareManifests = GetElapsedTime(ref time); m_TotalTime = GetElapsedTime(ref start); }