From fa9fe329d4fef540dc2db649c7c212f474df7d5d Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Fri, 25 Oct 2024 12:19:23 +0100 Subject: [PATCH] format --- .../Serialization/ChannelLoader.cs | 12 ++++++++---- .../Serialisation/V2/Receive/ObjectLoader.cs | 4 +--- .../Serialisation/V2/SQLiteCacheManager.cs | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs b/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs index 474c1b0c..d7bc96df 100644 --- a/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs +++ b/src/Speckle.Sdk.Dependencies/Serialization/ChannelLoader.cs @@ -6,7 +6,7 @@ public abstract class ChannelLoader { private const int HTTP_ID_CHUNK_SIZE = 500; private const int MAX_PARALLELISM_HTTP = 4; - + protected async Task GetAndCache(IEnumerable allChildrenIds, CancellationToken cancellationToken = default) => await allChildrenIds .ToChannel(cancellationToken: cancellationToken) @@ -14,16 +14,20 @@ await allChildrenIds .Filter(x => x is not null) .Batch(HTTP_ID_CHUNK_SIZE) .WithTimeout(TimeSpan.FromSeconds(2)) - .PipeAsync(MAX_PARALLELISM_HTTP, async x => await DownloadAndCache(x).ConfigureAwait(false), -1, false, cancellationToken) + .PipeAsync( + MAX_PARALLELISM_HTTP, + async x => await DownloadAndCache(x).ConfigureAwait(false), + -1, + false, + cancellationToken + ) .Join() .ReadAllConcurrently(Environment.ProcessorCount, SaveToCache, cancellationToken) .ConfigureAwait(false); - public abstract string? CheckCache(string id); public abstract Task> DownloadAndCache(List ids); public abstract void SaveToCache((string, string) x); - } diff --git a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs index 4f89cbd1..e890f977 100644 --- a/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs +++ b/src/Speckle.Sdk/Serialisation/V2/Receive/ObjectLoader.cs @@ -13,7 +13,6 @@ public sealed class ObjectLoader( IProgress? progress ) : ChannelLoader, IObjectLoader { - private int? _allChildrenCount; private long _checkCache; private long _cached; @@ -48,8 +47,7 @@ CancellationToken cancellationToken .Where(x => !x.StartsWith("blob", StringComparison.Ordinal)) .ToList(); _allChildrenCount = allChildrenIds.Count; - await GetAndCache(allChildrenIds, cancellationToken) - .ConfigureAwait(false); + await GetAndCache(allChildrenIds, cancellationToken).ConfigureAwait(false); //save the root last to shortcut later sqLiteCacheManager.SaveObjectSync(rootId, rootJson); diff --git a/src/Speckle.Sdk/Serialisation/V2/SQLiteCacheManager.cs b/src/Speckle.Sdk/Serialisation/V2/SQLiteCacheManager.cs index 3ea989ac..42309985 100644 --- a/src/Speckle.Sdk/Serialisation/V2/SQLiteCacheManager.cs +++ b/src/Speckle.Sdk/Serialisation/V2/SQLiteCacheManager.cs @@ -99,7 +99,7 @@ public bool HasObject(string objectId) bool rowFound = reader.Read(); return rowFound; } - + public void SaveObjectSync(string hash, string serializedObject) { using var c = new SqliteConnection(_connectionString);