@@ -208,39 +208,50 @@ private void CacheHasBeenInvalidated(CacheType cacheType)
208208 switch ( cacheType )
209209 {
210210 case CacheType . Branches :
211- repositoryManager ? . UpdateBranches ( ) . Start ( ) ;
211+ repositoryManager ? . UpdateBranches ( ) . Catch ( ex => InvalidationFailed ( ex , cacheType ) ) . Start ( ) ;
212212 break ;
213213
214214 case CacheType . GitLog :
215- repositoryManager ? . UpdateGitLog ( ) . Start ( ) ;
215+ repositoryManager ? . UpdateGitLog ( ) . Catch ( ex => InvalidationFailed ( ex , cacheType ) ) . Start ( ) ;
216216 break ;
217217
218218 case CacheType . GitAheadBehind :
219- repositoryManager ? . UpdateGitAheadBehindStatus ( ) . Start ( ) ;
219+ repositoryManager ? . UpdateGitAheadBehindStatus ( ) . Catch ( ex => InvalidationFailed ( ex , cacheType ) ) . Start ( ) ;
220220 break ;
221221
222222 case CacheType . GitLocks :
223223 if ( CurrentRemote != null )
224- repositoryManager ? . UpdateLocks ( ) . Start ( ) ;
224+ {
225+ repositoryManager ? . UpdateLocks ( ) . Catch ( ex => InvalidationFailed ( ex , cacheType ) ) . Start ( ) ;
226+ }
225227 break ;
226228
227229 case CacheType . GitUser :
228230 // user handles its own invalidation event
229231 break ;
230232
231233 case CacheType . RepositoryInfo :
232- repositoryManager ? . UpdateRepositoryInfo ( ) . Start ( ) ;
234+ repositoryManager ? . UpdateRepositoryInfo ( ) . Catch ( ex => InvalidationFailed ( ex , cacheType ) ) . Start ( ) ;
233235 break ;
234236
235237 case CacheType . GitStatus :
236- repositoryManager ? . UpdateGitStatus ( ) . Start ( ) ;
238+ repositoryManager ? . UpdateGitStatus ( ) . Catch ( ex => InvalidationFailed ( ex , cacheType ) ) . Start ( ) ;
237239 break ;
238240
239241 default :
240242 throw new ArgumentOutOfRangeException ( nameof ( cacheType ) , cacheType , null ) ;
241243 }
242244 }
243245
246+ private bool InvalidationFailed ( Exception ex , CacheType cacheType )
247+ {
248+ Logger . Warning ( ex , "Error invalidating {0}" , cacheType ) ;
249+ var managedCache = cacheContainer . GetCache ( cacheType ) ;
250+ managedCache . ResetInvalidation ( ) ;
251+ return false ;
252+ }
253+
254+
244255 private void RepositoryManagerOnCurrentBranchUpdated ( ConfigBranch ? branch , ConfigRemote ? remote , string head )
245256 {
246257 taskManager . RunInUI ( ( ) =>
@@ -254,7 +265,7 @@ private void RepositoryManagerOnCurrentBranchUpdated(ConfigBranch? branch, Confi
254265 name = null ;
255266 cloneUrl = null ;
256267 cacheContainer . RepositoryInfoCache . UpdateData ( data ) ;
257-
268+
258269 // force refresh of the Name and CloneUrl propertys
259270 var n = Name ;
260271 } ) ;
@@ -485,6 +496,7 @@ private void UpdateUserAndEmail()
485496 }
486497
487498 gitClient . GetConfigUserAndEmail ( )
499+ . Catch ( InvalidationFailed )
488500 . ThenInUI ( ( success , value ) =>
489501 {
490502 if ( success )
@@ -494,7 +506,15 @@ private void UpdateUserAndEmail()
494506 }
495507 } ) . Start ( ) ;
496508 }
497-
509+
510+ private bool InvalidationFailed ( Exception ex )
511+ {
512+ Logger . Warning ( ex , "Error invalidating user cache" ) ;
513+ var managedCache = cacheContainer . GetCache ( CacheType . GitUser ) ;
514+ managedCache . ResetInvalidation ( ) ;
515+ return false ;
516+ }
517+
498518 public string Name
499519 {
500520 get { return cacheContainer . GitUserCache . Name ; }
0 commit comments