From 033ff6b721b0fa20a44acd9e50178901a92a204c Mon Sep 17 00:00:00 2001 From: Arlo Godfrey Date: Wed, 17 Jul 2024 21:03:04 -0500 Subject: [PATCH] Release 0.16.5. Fixes and cleanup in CachedNameApi. [Fixes] Fixed serialization issues with CachedNameApi. Fixed multi-publishing in CachedNameApi when flushing after using both Path and Cid overloads. --- src/Cache/CachedNameApi.cs | 23 +++++++++++++---------- src/Cache/KuboCacheSerializerContext.cs | 3 +++ src/OwlCore.Kubo.csproj | 7 ++++++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Cache/CachedNameApi.cs b/src/Cache/CachedNameApi.cs index 7757b80..741884b 100644 --- a/src/Cache/CachedNameApi.cs +++ b/src/Cache/CachedNameApi.cs @@ -2,6 +2,7 @@ using Ipfs; using Ipfs.CoreApi; using OwlCore.ComponentModel; +using OwlCore.Diagnostics; using OwlCore.Extensions; using OwlCore.Storage; @@ -25,7 +26,7 @@ public record PublishedPathName(string path, bool resolve, string key, TimeSpan? /// /// The cached record for a published cid name in a . /// - public record PublishedCidName(Cid id, string key, TimeSpan? lifetime, NamedContent returnValue); + public record PublishedCidName(string cid, string key, TimeSpan? lifetime, NamedContent returnValue); /// /// The cached record for a resolved name in a . @@ -89,10 +90,8 @@ public async Task FlushAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - Console.WriteLine($"Flushing key {item.key} with value {item.id}"); - // Publish to ipfs - var result = await Inner.PublishAsync(item.id, item.key, item.lifetime, cancellationToken); + var result = await Inner.PublishAsync(item.cid, item.key, item.lifetime, cancellationToken); // Verify result matches original returned data _ = Guard.Equals(result.ContentPath, item.returnValue.ContentPath); @@ -107,8 +106,6 @@ public async Task FlushAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); - Console.WriteLine($"Flushing key {item.key} with value {item.path}"); - // Publish to ipfs var result = await Inner.PublishAsync(item.path, item.resolve, item.key, item.lifetime, cancellationToken); @@ -128,8 +125,11 @@ public async Task PublishAsync(string path, bool resolve = true, s { using (await _cacheUpdateMutex.DisposableWaitAsync(cancel)) { - if (PublishedStringNamedContent.FirstOrDefault(x => x.key == key) is { } existing) - PublishedStringNamedContent.Remove(existing); + if (PublishedCidNamedContent.FirstOrDefault(x => x.key == key) is { } existingCidNamedContent) + PublishedCidNamedContent.Remove(existingCidNamedContent); + + if (PublishedStringNamedContent.FirstOrDefault(x => x.key == key) is { } existingStringNameContent) + PublishedStringNamedContent.Remove(existingStringNameContent); var keys = await KeyApi.ListAsync(cancel); var existingKey = keys.FirstOrDefault(x => x.Name == key); @@ -147,8 +147,11 @@ public async Task PublishAsync(Cid id, string key = "self", TimeSp { using (await _cacheUpdateMutex.DisposableWaitAsync(cancel)) { - if (PublishedCidNamedContent.FirstOrDefault(x => x.key == key) is { } existing) - PublishedCidNamedContent.Remove(existing); + if (PublishedCidNamedContent.FirstOrDefault(x => x.key == key) is { } existingCidNamedContent) + PublishedCidNamedContent.Remove(existingCidNamedContent); + + if (PublishedStringNamedContent.FirstOrDefault(x => x.key == key) is { } existingStringNameContent) + PublishedStringNamedContent.Remove(existingStringNameContent); var keys = await KeyApi.ListAsync(cancel); var existingKey = keys.FirstOrDefault(x => x.Name == key); diff --git a/src/Cache/KuboCacheSerializerContext.cs b/src/Cache/KuboCacheSerializerContext.cs index 30e41a7..9122b1f 100644 --- a/src/Cache/KuboCacheSerializerContext.cs +++ b/src/Cache/KuboCacheSerializerContext.cs @@ -11,6 +11,9 @@ namespace OwlCore.Kubo.Cache; [JsonSerializable(typeof(int))] [JsonSerializable(typeof(List))] [JsonSerializable(typeof(List))] +[JsonSerializable(typeof(List))] +[JsonSerializable(typeof(List))] +[JsonSerializable(typeof(List))] public partial class KuboCacheSerializerContext : JsonSerializerContext { } \ No newline at end of file diff --git a/src/OwlCore.Kubo.csproj b/src/OwlCore.Kubo.csproj index da44198..f0b2687 100644 --- a/src/OwlCore.Kubo.csproj +++ b/src/OwlCore.Kubo.csproj @@ -14,13 +14,18 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb Arlo Godfrey - 0.16.4 + 0.16.5 OwlCore An essential toolkit for Kubo, IPFS and the distributed web. LICENSE.txt +--- 0.16.5 --- +[Fixes] +Fixed serialization issues with CachedNameApi. +Fixed multi-publishing in CachedNameApi when flushing after using both Path and Cid overloads. + --- 0.16.4 --- [Fixes] Fixed decryption on AesPasswordEncryptedPubSub, addressed usage of deprecated Rfc2898DeriveBytes constructor.