@@ -2513,30 +2513,37 @@ private void CalcMatchedFilesForSearching()
25132513
25142514 private void AutoFetchImpl ( object sender )
25152515 {
2516- if ( ! _settings . EnableAutoFetch || _isAutoFetching )
2517- return ;
2516+ try
2517+ {
2518+ if ( ! _settings . EnableAutoFetch || _isAutoFetching )
2519+ return ;
25182520
2519- var lockFile = Path . Combine ( _gitDir , "index.lock" ) ;
2520- if ( File . Exists ( lockFile ) )
2521- return ;
2521+ var lockFile = Path . Combine ( _gitDir , "index.lock" ) ;
2522+ if ( File . Exists ( lockFile ) )
2523+ return ;
25222524
2523- var now = DateTime . Now ;
2524- var desire = _lastFetchTime . AddMinutes ( _settings . AutoFetchInterval ) ;
2525- if ( desire > now )
2526- return ;
2525+ var now = DateTime . Now ;
2526+ var desire = _lastFetchTime . AddMinutes ( _settings . AutoFetchInterval ) ;
2527+ if ( desire > now )
2528+ return ;
25272529
2528- var remotes = new List < string > ( ) ;
2529- lock ( _lockRemotes )
2530+ var remotes = new List < string > ( ) ;
2531+ lock ( _lockRemotes )
2532+ {
2533+ foreach ( var remote in _remotes )
2534+ remotes . Add ( remote . Name ) ;
2535+ }
2536+
2537+ Dispatcher . UIThread . Invoke ( ( ) => IsAutoFetching = true ) ;
2538+ foreach ( var remote in remotes )
2539+ new Commands . Fetch ( _fullpath , remote , false , false , null ) { RaiseError = false } . Exec ( ) ;
2540+ _lastFetchTime = DateTime . Now ;
2541+ Dispatcher . UIThread . Invoke ( ( ) => IsAutoFetching = false ) ;
2542+ }
2543+ catch
25302544 {
2531- foreach ( var remote in _remotes )
2532- remotes . Add ( remote . Name ) ;
2545+ // DO nothing, but prevent `System.AggregateException`
25332546 }
2534-
2535- Dispatcher . UIThread . Invoke ( ( ) => IsAutoFetching = true ) ;
2536- foreach ( var remote in remotes )
2537- new Commands . Fetch ( _fullpath , remote , false , false , null ) { RaiseError = false } . Exec ( ) ;
2538- _lastFetchTime = DateTime . Now ;
2539- Dispatcher . UIThread . Invoke ( ( ) => IsAutoFetching = false ) ;
25402547 }
25412548
25422549 private string _fullpath = string . Empty ;
0 commit comments