about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
m---------ArcaneLibs0
-rw-r--r--LibMatrix/Homeservers/Extensions/NamedCaches/NamedCache.cs11
2 files changed, 9 insertions, 2 deletions
diff --git a/ArcaneLibs b/ArcaneLibs
-Subproject d271210163fe7da268e026e434d3d18b5a63ea9
+Subproject 98913a604fa40d1d850d9ef5666823a64244ba5
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<T>(AuthenticatedHomeserverGeneric hs, string name) where /// </summary> /// <returns>The updated data</returns> public async Task<Dictionary<string, T>> ReadCacheMapAsync() { - _cache = await hs.GetAccountDataAsync<Dictionary<string, T>>(name); + try { + _cache = await hs.GetAccountDataAsync<Dictionary<string, T>>(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<T>(AuthenticatedHomeserverGeneric hs, string name) where var removedValue = cache[key]; cache.Remove(key); await hs.SetAccountDataAsync(name, cache); - + if (!unsafeUseCache) _lock.Release();