@@ -560,7 +560,8 @@ public void Open()
560
560
_selectedViewIndex = 0 ;
561
561
562
562
_workingCopy . CommitMessage = _settings . LastCommitMessage ;
563
- _autoFetchTimer = new Timer ( AutoFetchImpl , null , 5000 , 5000 ) ;
563
+ _lastFetchTime = DateTime . Now ;
564
+ _autoFetchTimer = new Timer ( AutoFetchInBackground , null , 5000 , 5000 ) ;
564
565
RefreshAll ( ) ;
565
566
}
566
567
@@ -1194,9 +1195,7 @@ public void RefreshBranches()
1194
1195
1195
1196
Dispatcher . UIThread . Invoke ( ( ) =>
1196
1197
{
1197
- lock ( _lockRemotes )
1198
- Remotes = remotes ;
1199
-
1198
+ Remotes = remotes ;
1200
1199
Branches = branches ;
1201
1200
CurrentBranch = branches . Find ( x => x . IsCurrent ) ;
1202
1201
LocalBranchTrees = builder . Locals ;
@@ -1960,13 +1959,19 @@ private void CalcMatchedFilesForSearching()
1960
1959
MatchedFilesForSearching = matched ;
1961
1960
}
1962
1961
1963
- private async void AutoFetchImpl ( object sender )
1962
+ private void AutoFetchInBackground ( object sender )
1964
1963
{
1965
- try
1964
+ Dispatcher . UIThread . Post ( async ( ) =>
1966
1965
{
1967
- if ( ! _settings . EnableAutoFetch || _isAutoFetching )
1966
+ if ( _settings == null || ! _settings . EnableAutoFetch )
1968
1967
return ;
1969
1968
1969
+ if ( ! CanCreatePopup ( ) )
1970
+ {
1971
+ _lastFetchTime = DateTime . Now ;
1972
+ return ;
1973
+ }
1974
+
1970
1975
var lockFile = Path . Combine ( _gitDir , "index.lock" ) ;
1971
1976
if ( File . Exists ( lockFile ) )
1972
1977
return ;
@@ -1976,36 +1981,25 @@ private async void AutoFetchImpl(object sender)
1976
1981
if ( desire > now )
1977
1982
return ;
1978
1983
1979
- var remotes = new List < string > ( ) ;
1980
- lock ( _lockRemotes )
1981
- {
1982
- foreach ( var remote in _remotes )
1983
- remotes . Add ( remote . Name ) ;
1984
- }
1985
-
1986
- Dispatcher . UIThread . Invoke ( ( ) => IsAutoFetching = true ) ;
1984
+ IsAutoFetching = true ;
1987
1985
1988
1986
if ( _settings . FetchAllRemotes )
1989
1987
{
1990
- foreach ( var remote in remotes )
1991
- await new Commands . Fetch ( _fullpath , remote , false , false ) { RaiseError = false } . RunAsync ( ) ;
1988
+ foreach ( var remote in _remotes )
1989
+ await new Commands . Fetch ( _fullpath , remote . Name , false , false ) { RaiseError = false } . RunAsync ( ) ;
1992
1990
}
1993
- else if ( remotes . Count > 0 )
1991
+ else if ( _remotes . Count > 0 )
1994
1992
{
1995
1993
var remote = string . IsNullOrEmpty ( _settings . DefaultRemote ) ?
1996
- remotes . Find ( x => x . Equals ( _settings . DefaultRemote , StringComparison . Ordinal ) ) :
1997
- remotes [ 0 ] ;
1994
+ _remotes . Find ( x => x . Name . Equals ( _settings . DefaultRemote , StringComparison . Ordinal ) ) :
1995
+ _remotes [ 0 ] ;
1998
1996
1999
- await new Commands . Fetch ( _fullpath , remote , false , false ) { RaiseError = false } . RunAsync ( ) ;
1997
+ await new Commands . Fetch ( _fullpath , remote . Name , false , false ) { RaiseError = false } . RunAsync ( ) ;
2000
1998
}
2001
1999
2002
2000
_lastFetchTime = DateTime . Now ;
2003
- Dispatcher . UIThread . Invoke ( ( ) => IsAutoFetching = false ) ;
2004
- }
2005
- catch
2006
- {
2007
- // DO nothing, but prevent `System.AggregateException`
2008
- }
2001
+ IsAutoFetching = false ;
2002
+ } ) ;
2009
2003
}
2010
2004
2011
2005
private string _fullpath = string . Empty ;
@@ -2037,7 +2031,6 @@ private async void AutoFetchImpl(object sender)
2037
2031
private List < string > _matchedFilesForSearching = null ;
2038
2032
2039
2033
private string _filter = string . Empty ;
2040
- private readonly Lock _lockRemotes = new ( ) ;
2041
2034
private List < Models . Remote > _remotes = new List < Models . Remote > ( ) ;
2042
2035
private List < Models . Branch > _branches = new List < Models . Branch > ( ) ;
2043
2036
private Models . Branch _currentBranch = null ;
0 commit comments