@@ -153,12 +153,9 @@ def __init__(
153
153
super ().__init__ (** kwargs )
154
154
155
155
def reload_projects (self ) -> None :
156
- repos : list [Any ] = []
157
-
158
- if self .project_cache_file .exists ():
159
- repos = json .loads (self .project_cache_file .read_text ())
156
+ repos : list [Any ] = refresh_projects (self .token .get (), self .project_cache_file )
160
157
161
- refresh_projects ( self . token . get (), self . project_cache_file )
158
+ log . msg ( repos )
162
159
163
160
atomic_write_file (self .project_cache_file , json .dumps (repos ))
164
161
@@ -569,6 +566,19 @@ def load_projects(self) -> list["GitProject"]:
569
566
json .loads (self .config .project_cache_file .read_text ()),
570
567
key = lambda x : x ["full_name" ],
571
568
)
569
+
570
+ if isinstance (self .auth_backend , GithubAppAuthBackend ):
571
+ dropped_repos = list (
572
+ filter (lambda repo : not "installation_id" in repo , repos )
573
+ )
574
+ if dropped_repos :
575
+ tlog .info (
576
+ "Dropped projects follow, refresh will follow after initialisation:"
577
+ )
578
+ for dropped_repo in dropped_repos :
579
+ tlog .info (f"\t Dropping repo { dropped_repo ['full_name' ]} " )
580
+ repos = list (filter (lambda repo : "installation_id" in repo , repos ))
581
+
572
582
tlog .info (f"Loading { len (repos )} cached repositories." )
573
583
return list (
574
584
filter (
@@ -587,7 +597,16 @@ def load_projects(self) -> list["GitProject"]:
587
597
)
588
598
589
599
def are_projects_cached (self ) -> bool :
590
- return self .config .project_cache_file .exists ()
600
+ if not self .config .project_cache_file .exists ():
601
+ return False
602
+
603
+ all_have_installation_id = True
604
+ for project in json .loads (self .config .project_cache_file .read_text ()):
605
+ if not "installation_id" in project :
606
+ all_have_installation_id = False
607
+ break
608
+
609
+ return all_have_installation_id
591
610
592
611
@property
593
612
def type (self ) -> str :
0 commit comments