Fix GitHub App backend failing if project-id-map disappears

Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
magic_rb 2024-06-12 17:36:43 +02:00
parent 467b9164de
commit 0ac5dcb33d
Failed to generate hash of commit

View file

@ -381,6 +381,9 @@ class GithubAppAuthBackend(GithubAuthBackend):
self.auth_type.app_project_id_map_name.read_text() self.auth_type.app_project_id_map_name.read_text()
) )
else: else:
tlog.info(
"~project-id-map~ is not present, GitHub project reload will follow."
)
self.project_id_map = {} self.project_id_map = {}
def get_general_token(self) -> RepoToken: def get_general_token(self) -> RepoToken:
@ -600,6 +603,12 @@ class GithubBackend(GitBackend):
if not self.config.project_cache_file.exists(): if not self.config.project_cache_file.exists():
return False return False
if (
isinstance(self.config.auth_type, AuthTypeApp)
and not self.config.auth_type.app_project_id_map_name.exists()
):
return False
all_have_installation_id = True all_have_installation_id = True
for project in json.loads(self.config.project_cache_file.read_text()): for project in json.loads(self.config.project_cache_file.read_text()):
if not "installation_id" in project: if not "installation_id" in project: