From 5dc05ea3fefa6afb3d00d7411ef401040a58c167 Mon Sep 17 00:00:00 2001 From: magic_rb Date: Sun, 2 Jun 2024 16:12:09 +0200 Subject: [PATCH] Fix GitHub installation tokens not getting updated in the cache file Signed-off-by: magic_rb --- buildbot_nix/github/installation_token.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/buildbot_nix/github/installation_token.py b/buildbot_nix/github/installation_token.py index a5affce..6714246 100644 --- a/buildbot_nix/github/installation_token.py +++ b/buildbot_nix/github/installation_token.py @@ -86,7 +86,7 @@ class InstallationToken(RepoToken): # token: "token" # } # } - installations_token_map: dict[int, Any] + installations_token_map: dict[str, Any] if self.installations_token_map_name.exists(): installations_token_map = json.loads( self.installations_token_map_name.read_text() @@ -94,10 +94,14 @@ class InstallationToken(RepoToken): else: installations_token_map = {} - installations_token_map[self.installation_id] = { - "expiration": self.expiration.isoformat(), - "token": self.token, - } + installations_token_map.update( + { + str(self.installation_id): { + "expiration": self.expiration.isoformat(), + "token": self.token, + } + } + ) atomic_write_file( self.installations_token_map_name, json.dumps(installations_token_map)