From 59782022508f4a9eef6cf719f2cd47060cb99483 Mon Sep 17 00:00:00 2001 From: Hatry1337 Date: Wed, 10 Jan 2024 11:08:43 +0300 Subject: [PATCH] usermanager cache fix (again) (is that fix for all our problems?) --- package.json | 2 +- src/UserManager.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 028c0ee..41a5cd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "synergy3", - "version": "3.14.5", + "version": "3.14.6", "description": "Synergy 3 - Powerful Discord BOT Framework.", "license": "MIT", "author": { diff --git a/src/UserManager.ts b/src/UserManager.ts index 5fd5e17..c1c9913 100644 --- a/src/UserManager.ts +++ b/src/UserManager.ts @@ -187,10 +187,7 @@ export default class UserManager extends CachedManager{ return user; } - public async forceStorageUpdate(unifiedId: UnifiedIdString, transaction?: Transaction) { - let user = await this.cacheStorage.get(unifiedId); - if(!user) return; - + public async forceStorageUpdate(user: User, transaction?: Transaction) { let t = transaction; if(!t) { t = await sequelize().transaction(); @@ -250,12 +247,16 @@ export default class UserManager extends CachedManager{ public override async destroy() { for(let k of this.cacheStorage.keys()) { - await this.onCacheEntryDeleted(k, this.cacheStorage.get(k)!); + try { + await this.onCacheEntryDeleted(k, this.cacheStorage.get(k)!); + } catch (e) { + GlobalLogger.root.error("UserManager.destroy entry with key", k, "failed:", e); + } } await super.destroy(); } private async onCacheEntryDeleted(unifiedId: UnifiedIdString, user: User) { - await this.forceStorageUpdate(unifiedId); + await this.forceStorageUpdate(user); } } \ No newline at end of file