fix: don't keep Messenger from starting when torrent client fails to

start

There are various cases that could make the torrent client fail to
start. We don't want this to keep the entire messenger from starting.
This commit is contained in:
Pascal Precht 2022-12-05 18:30:07 +01:00 committed by r4bbit
parent 195c149f47
commit 8ac154ee0c
3 changed files with 8 additions and 5 deletions

View File

@ -158,7 +158,7 @@ func (m *Manager) Start() error {
if m.torrentConfig != nil && m.torrentConfig.Enabled {
err := m.StartTorrentClient()
return err
m.logger.Warn("couldn't start torrent client", zap.Error(err))
}
return nil

View File

@ -705,7 +705,7 @@ func (m *Messenger) Start() (*MessengerResponse, error) {
return nil, err
}
if m.config.torrentConfig != nil && m.config.torrentConfig.Enabled {
if m.config.torrentConfig != nil && m.config.torrentConfig.Enabled && m.communitiesManager.TorrentClientStarted() {
adminCommunities, err := m.communitiesManager.Created()
if err == nil && len(adminCommunities) > 0 {
available := m.SubscribeMailserverAvailable()

View File

@ -1076,7 +1076,7 @@ func (m *Messenger) EditCommunity(request *requests.EditCommunity) (*MessengerRe
id := community.ID()
if m.config.torrentConfig != nil && m.config.torrentConfig.Enabled {
if m.config.torrentConfig != nil && m.config.torrentConfig.Enabled && m.communitiesManager.TorrentClientStarted() {
if !communitySettings.HistoryArchiveSupportEnabled {
m.communitiesManager.StopHistoryArchiveTasksInterval(id)
} else if !m.communitiesManager.IsSeedingHistoryArchiveTorrent(id) {
@ -1139,7 +1139,7 @@ func (m *Messenger) ImportCommunity(ctx context.Context, key *ecdsa.PrivateKey)
return nil, err
}
if m.config.torrentConfig != nil && m.config.torrentConfig.Enabled {
if m.config.torrentConfig != nil && m.config.torrentConfig.Enabled && m.communitiesManager.TorrentClientStarted() {
var communities []*communities.Community
communities = append(communities, community)
go m.InitHistoryArchiveTasks(communities)
@ -2981,7 +2981,10 @@ func (m *Messenger) RequestImportDiscordCommunity(request *requests.ImportDiscor
}
}
if m.config.torrentConfig != nil && m.config.torrentConfig.Enabled && communitySettings.HistoryArchiveSupportEnabled {
if m.config.torrentConfig != nil &&
m.config.torrentConfig.Enabled &&
communitySettings.HistoryArchiveSupportEnabled &&
m.communitiesManager.TorrentClientStarted() {
err = m.communitiesManager.SeedHistoryArchiveTorrent(discordCommunity.ID())
if err != nil {