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 {
|
if m.ownerVerifier != nil {
|
||||||
m.runOwnerVerificationLoop()
|
m.runOwnerVerificationLoop()
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if m.torrentConfig != nil && m.torrentConfig.Enabled {
|
func (m *Manager) SetOnline(online bool) {
|
||||||
|
if online {
|
||||||
|
if m.torrentConfig != nil && m.torrentConfig.Enabled && !m.TorrentClientStarted() {
|
||||||
err := m.StartTorrentClient()
|
err := m.StartTorrentClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.LogStdout("couldn't start torrent client", zap.Error(err))
|
m.LogStdout("couldn't start torrent client", zap.Error(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) runENSVerificationLoop() {
|
func (m *Manager) runENSVerificationLoop() {
|
||||||
|
|
|
@ -501,6 +501,16 @@ func (s *ManagerSuite) TestStopTorrentClient_ShouldStopHistoryArchiveTasks() {
|
||||||
s.Require().Equal(count, 0)
|
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() {
|
func (s *ManagerSuite) TestCreateHistoryArchiveTorrent_WithoutMessages() {
|
||||||
|
|
||||||
torrentConfig := buildTorrentConfig()
|
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
|
// Publish contact code
|
||||||
if online && m.shouldPublishContactCode {
|
if online && m.shouldPublishContactCode {
|
||||||
if err := m.publishContactCode(); err != nil {
|
if err := m.publishContactCode(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue