@@ -19,6 +19,7 @@ public class GitHubApiRepositoriesService
19
19
readonly IAnalyticsService _analyticsService ;
20
20
readonly GitHubUserService _gitHubUserService ;
21
21
readonly GitHubApiV3Service _gitHubApiV3Service ;
22
+ readonly RepositoryDatabase _repositoryDatabase ;
22
23
readonly ReferringSitesDatabase _referringSitesDatabase ;
23
24
readonly GitHubApiStatusService _gitHubApiStatusService ;
24
25
readonly GitHubGraphQLApiService _gitHubGraphQLApiService ;
@@ -27,6 +28,7 @@ public GitHubApiRepositoriesService(FavIconService favIconService,
27
28
IAnalyticsService analyticsService ,
28
29
GitHubUserService gitHubUserService ,
29
30
GitHubApiV3Service gitHubApiV3Service ,
31
+ RepositoryDatabase repositoryDatabase ,
30
32
ReferringSitesDatabase referringSitesDatabase ,
31
33
GitHubApiStatusService gitHubApiStatusService ,
32
34
GitHubGraphQLApiService gitHubGraphQLApiService )
@@ -35,6 +37,7 @@ public GitHubApiRepositoriesService(FavIconService favIconService,
35
37
_analyticsService = analyticsService ;
36
38
_gitHubUserService = gitHubUserService ;
37
39
_gitHubApiV3Service = gitHubApiV3Service ;
40
+ _repositoryDatabase = repositoryDatabase ;
38
41
_referringSitesDatabase = referringSitesDatabase ;
39
42
_gitHubApiStatusService = gitHubApiStatusService ;
40
43
_gitHubGraphQLApiService = gitHubGraphQLApiService ;
@@ -138,9 +141,9 @@ public async IAsyncEnumerable<Repository> UpdateRepositoriesWithViewsClonesAndSt
138
141
await getCloneStatisticsTask . ConfigureAwait ( false ) ,
139
142
await getStarGazrsTask . ConfigureAwait ( false ) ) ;
140
143
}
141
- catch ( ApiException e ) when ( _gitHubApiStatusService . IsAbuseRateLimit ( e . Headers , out var timespan ) && timespan is TimeSpan retryTimeSpan )
144
+ catch ( ApiException e ) when ( _gitHubApiStatusService . IsAbuseRateLimit ( e . Headers , out var timespan ) )
142
145
{
143
- OnAbuseRateLimitFound_UpdateRepositoriesWithViewsClonesAndStarsData ( repository , retryTimeSpan ) ;
146
+ OnAbuseRateLimitFound_UpdateRepositoriesWithViewsClonesAndStarsData ( repository , timespan . Value ) ;
144
147
145
148
return ( null , null , null ) ;
146
149
}
@@ -155,6 +158,17 @@ await getCloneStatisticsTask.ConfigureAwait(false),
155
158
reportException ( e ) ;
156
159
157
160
return ( null , null , null ) ;
161
+ }
162
+ catch ( ApiException e ) when ( e . StatusCode is System . Net . HttpStatusCode . NotFound ) // Repository deleted from GitHub but has not yet been deleted from local SQLite Database
163
+ {
164
+ reportException ( e ) ;
165
+
166
+ var repositoryFromDatabase = await _repositoryDatabase . GetRepository ( repository . Url ) . ConfigureAwait ( false ) ;
167
+ if ( repositoryFromDatabase is null )
168
+ throw ;
169
+
170
+ await _repositoryDatabase . DeleteRepository ( repository ) . ConfigureAwait ( false ) ;
171
+ return ( null , null , null ) ;
158
172
}
159
173
160
174
void reportException ( in Exception e )
0 commit comments