From 4b508fa6216c6682925a42b67936b068e6db8e64 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sat, 19 Apr 2025 19:50:08 +0200 Subject: Update ArcaneLibs for Blazor a11y, return empty cache if not found in NamedCache --- LibMatrix/Homeservers/Extensions/NamedCaches/NamedCache.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'LibMatrix') diff --git a/LibMatrix/Homeservers/Extensions/NamedCaches/NamedCache.cs b/LibMatrix/Homeservers/Extensions/NamedCaches/NamedCache.cs index 9f11fa0..1f62637 100644 --- a/LibMatrix/Homeservers/Extensions/NamedCaches/NamedCache.cs +++ b/LibMatrix/Homeservers/Extensions/NamedCaches/NamedCache.cs @@ -13,7 +13,14 @@ public class NamedCache(AuthenticatedHomeserverGeneric hs, string name) where /// /// The updated data public async Task> ReadCacheMapAsync() { - _cache = await hs.GetAccountDataAsync>(name); + try { + _cache = await hs.GetAccountDataAsync>(name); + } + catch (MatrixException e) { + if (e is { ErrorCode: MatrixException.ErrorCodes.M_NOT_FOUND }) + _cache = []; + else throw; + } return _cache ?? new(); } @@ -54,7 +61,7 @@ public class NamedCache(AuthenticatedHomeserverGeneric hs, string name) where var removedValue = cache[key]; cache.Remove(key); await hs.SetAccountDataAsync(name, cache); - + if (!unsafeUseCache) _lock.Release(); -- cgit 1.5.1