mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
fix(irc): panic when creating indexer with irc (#986)
fix(irc): store channel panic
This commit is contained in:
parent
1f8804154e
commit
2af0021ce6
3 changed files with 14 additions and 18 deletions
|
@ -561,17 +561,16 @@ func (s *service) StoreNetwork(ctx context.Context, network *domain.IrcNetwork)
|
|||
}
|
||||
|
||||
if existingNetwork == nil {
|
||||
if err := s.repo.StoreNetwork(network); err != nil {
|
||||
if err := s.repo.StoreNetwork(ctx, network); err != nil {
|
||||
return err
|
||||
}
|
||||
s.log.Debug().Msgf("store network: %+v", network)
|
||||
|
||||
if network.Channels != nil {
|
||||
for _, channel := range network.Channels {
|
||||
if err := s.repo.StoreChannel(nil, network.ID, &channel); err != nil {
|
||||
if err := s.repo.StoreChannel(ctx, network.ID, &channel); err != nil {
|
||||
s.log.Error().Stack().Err(err).Msg("irc.storeChannel: error executing query")
|
||||
return errors.Wrap(err, "error storing channel on network")
|
||||
//return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -582,14 +581,14 @@ func (s *service) StoreNetwork(ctx context.Context, network *domain.IrcNetwork)
|
|||
// get channels for existing network
|
||||
existingChannels, err := s.repo.ListChannels(existingNetwork.ID)
|
||||
if err != nil {
|
||||
s.log.Error().Err(err).Msgf("failed to list channels for network %q", existingNetwork.Server)
|
||||
s.log.Error().Err(err).Msgf("failed to list channels for network %s", existingNetwork.Server)
|
||||
}
|
||||
existingNetwork.Channels = existingChannels
|
||||
|
||||
if network.Channels != nil {
|
||||
for _, channel := range network.Channels {
|
||||
// add channels. Make sure it doesn't delete before
|
||||
if err := s.repo.StoreChannel(nil, existingNetwork.ID, &channel); err != nil {
|
||||
if err := s.repo.StoreChannel(ctx, existingNetwork.ID, &channel); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -611,10 +610,9 @@ func (s *service) StoreNetwork(ctx context.Context, network *domain.IrcNetwork)
|
|||
// if nickserv account, nickserv password : changed - stay connected, and change those
|
||||
// if channels len : changes - join or leave
|
||||
|
||||
err := s.checkIfNetworkRestartNeeded(existingNetwork)
|
||||
if err != nil {
|
||||
s.log.Error().Err(err).Msgf("could not restart network: %+v", existingNetwork.Name)
|
||||
return errors.New("could not restart network: %v", existingNetwork.Name)
|
||||
if err := s.checkIfNetworkRestartNeeded(existingNetwork); err != nil {
|
||||
s.log.Error().Err(err).Msgf("could not restart network: %s", existingNetwork.Name)
|
||||
return errors.New("could not restart network: %s", existingNetwork.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue