+1
-1
@@ -455,7 +455,7 @@ func (s *service) Serve(ctx context.Context) error {
|
||||
// due to a config change through the API, let that finish successfully.
|
||||
timeout, cancel := context.WithTimeout(context.Background(), s.shutdownTimeout)
|
||||
defer cancel()
|
||||
if err := srv.Shutdown(timeout); err == timeout.Err() {
|
||||
if err := srv.Shutdown(timeout); errors.Is(err, timeout.Err()) {
|
||||
srv.Close()
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package beacon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net"
|
||||
"time"
|
||||
@@ -93,7 +94,8 @@ func writeBroadcasts(ctx context.Context, inbox <-chan []byte, port int) error {
|
||||
_, err = conn.WriteTo(bs, dst)
|
||||
conn.SetWriteDeadline(time.Time{})
|
||||
|
||||
if nerr, ok := err.(net.Error); ok && nerr.Timeout() {
|
||||
var nerr net.Error
|
||||
if errors.As(err, &nerr) && nerr.Timeout() {
|
||||
// Write timeouts should not happen. We treat it as a fatal
|
||||
// error on the socket.
|
||||
l.Debugln(err)
|
||||
|
||||
@@ -153,7 +153,7 @@ func (f FolderConfiguration) ModTimeWindow() time.Duration {
|
||||
}
|
||||
|
||||
func (f *FolderConfiguration) CreateMarker() error {
|
||||
if err := f.CheckPath(); err != ErrMarkerMissing {
|
||||
if err := f.CheckPath(); !errors.Is(err, ErrMarkerMissing) {
|
||||
return err
|
||||
}
|
||||
if f.MarkerName != DefaultMarkerName {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package connections
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
@@ -20,7 +21,8 @@ func fixupPort(uri *url.URL, defaultPort int) *url.URL {
|
||||
copyURI := *uri
|
||||
|
||||
host, port, err := net.SplitHostPort(uri.Host)
|
||||
if e, ok := err.(*net.AddrError); ok && strings.Contains(e.Err, "missing port") {
|
||||
e := &net.AddrError{}
|
||||
if errors.As(err, &e) && strings.Contains(e.Err, "missing port") {
|
||||
// addr is of the form "1.2.3.4" or "[fe80::1]"
|
||||
host = uri.Host
|
||||
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
|
||||
|
||||
@@ -406,7 +406,7 @@ func (c *rawConnection) readerLoop() {
|
||||
for {
|
||||
msg, err := c.readMessage(fourByteBuf)
|
||||
if err != nil {
|
||||
if err == errUnknownMessage {
|
||||
if errors.Is(err, errUnknownMessage) {
|
||||
// Unknown message types are skipped, for future extensibility.
|
||||
continue
|
||||
}
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ func (p *Process) Stop() (*os.ProcessState, error) {
|
||||
default:
|
||||
}
|
||||
|
||||
if _, err := p.Post("/rest/system/shutdown", nil); err != nil && err != io.ErrUnexpectedEOF {
|
||||
if _, err := p.Post("/rest/system/shutdown", nil); err != nil && !errors.Is(err, io.ErrUnexpectedEOF) {
|
||||
// Unexpected EOF is somewhat expected here, as we may exit before
|
||||
// returning something sensible.
|
||||
return nil, err
|
||||
|
||||
@@ -5,6 +5,7 @@ package client
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
@@ -137,7 +138,8 @@ func TestRelay(ctx context.Context, uri *url.URL, certs []tls.Certificate, sleep
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if _, ok := err.(*incorrectResponseCodeErr); !ok {
|
||||
incorrectResponseCodeErr := &incorrectResponseCodeErr{}
|
||||
if errors.As(err, &incorrectResponseCodeErr) {
|
||||
return fmt.Errorf("getting invitation: %w", err)
|
||||
}
|
||||
time.Sleep(sleep)
|
||||
|
||||
@@ -209,7 +209,7 @@ func (l *DowngradingListener) Accept() (net.Conn, error) {
|
||||
|
||||
// We failed to identify the socket type, pretend that everything is fine,
|
||||
// and pass it to the underlying handler, and let them deal with it.
|
||||
if err == ErrIdentificationFailed {
|
||||
if errors.Is(err, ErrIdentificationFailed) {
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -229,7 +229,8 @@ USER-AGENT: syncthing/%s
|
||||
|
||||
_, err = socket.WriteTo(search, &ssdp)
|
||||
if err != nil {
|
||||
if e, ok := err.(net.Error); !ok || !e.Timeout() {
|
||||
var e net.Error
|
||||
if !errors.As(err, &e) || !e.Timeout() {
|
||||
l.Debugln("UPnP discovery: sending search request:", err)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -101,8 +101,9 @@ func (v external) Archive(filePath string) error {
|
||||
combinedOutput, err := cmd.CombinedOutput()
|
||||
l.Debugln("external command output:", string(combinedOutput))
|
||||
if err != nil {
|
||||
if eerr, ok := err.(*exec.ExitError); ok && len(eerr.Stderr) > 0 {
|
||||
return fmt.Errorf("%v: %v", err, string(eerr.Stderr))
|
||||
eerr := &exec.ExitError{}
|
||||
if errors.As(err, &eerr) && len(eerr.Stderr) > 0 {
|
||||
return fmt.Errorf("%w: %v", err, string(eerr.Stderr))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user