From b886dde3d68a9fdde7c1a2a73e05a3219066bb2c Mon Sep 17 00:00:00 2001 From: jelveh Date: Tue, 21 Apr 2026 19:32:19 -0700 Subject: [PATCH] Await DB write and add UID cache key Make the DB update in AppES awaitable so the write completes before proceeding (avoids race conditions). Also add invalidation of the Redis object key for the app UID in AppInformationService to ensure cached entries keyed by uid are cleared after updates. --- src/backend/src/modules/apps/AppInformationService.js | 4 ++++ src/backend/src/om/entitystorage/AppES.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/src/modules/apps/AppInformationService.js b/src/backend/src/modules/apps/AppInformationService.js index 05a8fc8cc..7a18dcc77 100644 --- a/src/backend/src/modules/apps/AppInformationService.js +++ b/src/backend/src/modules/apps/AppInformationService.js @@ -123,6 +123,10 @@ class AppInformationService extends BaseService { value: appUid, rawIcon: false, }), + AppRedisCacheSpace.objectKey({ + lookup: 'uid', + value: appUid, + }), ]), AppRedisCacheSpace.invalidateAppStats(appUid), ]); diff --git a/src/backend/src/om/entitystorage/AppES.js b/src/backend/src/om/entitystorage/AppES.js index 69abe2ef5..4287d32af 100644 --- a/src/backend/src/om/entitystorage/AppES.js +++ b/src/backend/src/om/entitystorage/AppES.js @@ -300,7 +300,7 @@ class AppES extends BaseES { }; await svc_event.emit('app.new-icon', event); if ( typeof event.url === 'string' && event.url ) { - this.db.write( + await this.db.write( 'UPDATE apps SET icon = ? WHERE id = ? LIMIT 1', [event.url, insert_id], );