fix(communities)_: delay starting torrent client until connection is established
Fixes # 14510
This commit is contained in:
parent
529c658374
commit
6b5315b1fd
|
@ -444,15 +444,18 @@ func (m *Manager) Start() error {
|
|||
if m.ownerVerifier != nil {
|
||||
m.runOwnerVerificationLoop()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.torrentConfig != nil && m.torrentConfig.Enabled {
|
||||
err := m.StartTorrentClient()
|
||||
if err != nil {
|
||||
m.LogStdout("couldn't start torrent client", zap.Error(err))
|
||||
func (m *Manager) SetOnline(online bool) {
|
||||
if online {
|
||||
if m.torrentConfig != nil && m.torrentConfig.Enabled && !m.TorrentClientStarted() {
|
||||
err := m.StartTorrentClient()
|
||||
if err != nil {
|
||||
m.LogStdout("couldn't start torrent client", zap.Error(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) runENSVerificationLoop() {
|
||||
|
|
|
@ -501,6 +501,16 @@ func (s *ManagerSuite) TestStopTorrentClient_ShouldStopHistoryArchiveTasks() {
|
|||
s.Require().Equal(count, 0)
|
||||
}
|
||||
|
||||
func (s *ManagerSuite) TestStartTorrentClient_DelayedUntilOnline() {
|
||||
torrentConfig := buildTorrentConfig()
|
||||
s.manager.SetTorrentConfig(&torrentConfig)
|
||||
|
||||
s.Require().False(s.manager.TorrentClientStarted())
|
||||
|
||||
s.manager.SetOnline(true)
|
||||
s.Require().True(s.manager.TorrentClientStarted())
|
||||
}
|
||||
|
||||
func (s *ManagerSuite) TestCreateHistoryArchiveTorrent_WithoutMessages() {
|
||||
|
||||
torrentConfig := buildTorrentConfig()
|
||||
|
|
|
@ -899,6 +899,11 @@ func (m *Messenger) handleConnectionChange(online bool) {
|
|||
}
|
||||
}
|
||||
|
||||
// Update Communities manager
|
||||
if m.communitiesManager != nil {
|
||||
m.communitiesManager.SetOnline(online)
|
||||
}
|
||||
|
||||
// Publish contact code
|
||||
if online && m.shouldPublishContactCode {
|
||||
if err := m.publishContactCode(); err != nil {
|
||||
|
|
Loading…
Reference in New Issue