forked from Silverfish/proton-bridge
Other(refactor): Remove always-nil return value of (*Bridge).Close
This commit is contained in:
@ -109,12 +109,8 @@ func withBridge( //nolint:funlen
|
|||||||
return fmt.Errorf("could not create bridge: %w", err)
|
return fmt.Errorf("could not create bridge: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the bridge when we exit.
|
// Ensure we close bridge when we exit.
|
||||||
defer func() {
|
defer bridge.Close(c.Context)
|
||||||
if err := bridge.Close(c.Context); err != nil {
|
|
||||||
logrus.WithError(err).Error("Failed to close bridge")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
return fn(bridge, eventCh)
|
return fn(bridge, eventCh)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -347,7 +347,7 @@ func (bridge *Bridge) GetErrors() []error {
|
|||||||
return bridge.errors
|
return bridge.errors
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bridge *Bridge) Close(ctx context.Context) error {
|
func (bridge *Bridge) Close(ctx context.Context) {
|
||||||
// Close the IMAP server.
|
// Close the IMAP server.
|
||||||
if err := bridge.closeIMAP(ctx); err != nil {
|
if err := bridge.closeIMAP(ctx); err != nil {
|
||||||
logrus.WithError(err).Error("Failed to close IMAP server")
|
logrus.WithError(err).Error("Failed to close IMAP server")
|
||||||
@ -385,8 +385,6 @@ func (bridge *Bridge) Close(ctx context.Context) error {
|
|||||||
if err := bridge.vault.SetLastVersion(bridge.curVersion); err != nil {
|
if err := bridge.vault.SetLastVersion(bridge.curVersion); err != nil {
|
||||||
logrus.WithError(err).Error("Failed to save last version")
|
logrus.WithError(err).Error("Failed to save last version")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bridge *Bridge) publish(event events.Event) {
|
func (bridge *Bridge) publish(event events.Event) {
|
||||||
|
|||||||
@ -460,7 +460,7 @@ func withBridge(
|
|||||||
require.NoError(t, bridge.SetSMTPPort(0))
|
require.NoError(t, bridge.SetSMTPPort(0))
|
||||||
|
|
||||||
// Close the bridge when done.
|
// Close the bridge when done.
|
||||||
defer func() { require.NoError(t, bridge.Close(ctx)) }()
|
defer bridge.Close(ctx)
|
||||||
|
|
||||||
// Use the bridge.
|
// Use the bridge.
|
||||||
tests(bridge, mocks)
|
tests(bridge, mocks)
|
||||||
|
|||||||
@ -106,10 +106,12 @@ func (t *testCtx) startBridge() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *testCtx) stopBridge() error {
|
func (t *testCtx) stopBridge() error {
|
||||||
if err := t.bridge.Close(context.Background()); err != nil {
|
if t.bridge == nil {
|
||||||
return err
|
return fmt.Errorf("bridge is not running")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.bridge.Close(context.Background())
|
||||||
|
|
||||||
t.bridge = nil
|
t.bridge = nil
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -261,9 +261,7 @@ func (t *testCtx) close(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if t.bridge != nil {
|
if t.bridge != nil {
|
||||||
if err := t.bridge.Close(ctx); err != nil {
|
t.bridge.Close(ctx)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.api.Close()
|
t.api.Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user