Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
usermanager cache fix (again) (is that fix for all our problems?)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hatry1337 committed Jan 10, 2024
1 parent 0c1d32f commit 5978202
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "synergy3",
"version": "3.14.5",
"version": "3.14.6",
"description": "Synergy 3 - Powerful Discord BOT Framework.",
"license": "MIT",
"author": {
Expand Down
13 changes: 7 additions & 6 deletions src/UserManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ export default class UserManager extends CachedManager<User>{
return user;
}

public async forceStorageUpdate(unifiedId: UnifiedIdString, transaction?: Transaction) {
let user = await this.cacheStorage.get<User>(unifiedId);
if(!user) return;

public async forceStorageUpdate(user: User, transaction?: Transaction) {
let t = transaction;
if(!t) {
t = await sequelize().transaction();
Expand Down Expand Up @@ -250,12 +247,16 @@ export default class UserManager extends CachedManager<User>{

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);
}
}

0 comments on commit 5978202

Please sign in to comment.