@@ -136,7 +136,7 @@ func parseCrashReport(path string, report []byte) (*raven.Packet, error) {
|
|||||||
|
|
||||||
r := bytes.NewReader(report)
|
r := bytes.NewReader(report)
|
||||||
ctx, _, err := stack.ScanSnapshot(r, io.Discard, stack.DefaultOpts())
|
ctx, _, err := stack.ScanSnapshot(r, io.Discard, stack.DefaultOpts())
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && !errors.Is(err, io.EOF) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if ctx == nil || len(ctx.Goroutines) == 0 {
|
if ctx == nil || len(ctx.Goroutines) == 0 {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@@ -133,7 +134,8 @@ func connectToStdio(stdin <-chan string, conn net.Conn) {
|
|||||||
conn.SetReadDeadline(time.Now().Add(time.Millisecond))
|
conn.SetReadDeadline(time.Now().Add(time.Millisecond))
|
||||||
n, err := conn.Read(buf[0:])
|
n, err := conn.Read(buf[0:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
nerr, ok := err.(net.Error)
|
var nerr net.Error
|
||||||
|
ok := errors.As(err, &nerr)
|
||||||
if !ok || !nerr.Timeout() {
|
if !ok || !nerr.Timeout() {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -529,7 +529,8 @@ func (c *serveCmd) syncthingMain() {
|
|||||||
err = upgrade.To(release)
|
err = upgrade.To(release)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(*errNoUpgrade); ok || err == errTooEarlyUpgradeCheck || err == errTooEarlyUpgrade {
|
var noUpgradeErr *errNoUpgrade
|
||||||
|
if errors.As(err, &noUpgradeErr) || errors.Is(err, errTooEarlyUpgradeCheck) || errors.Is(err, errTooEarlyUpgrade) {
|
||||||
slog.Debug("Initial automatic upgrade", slogutil.Error(err))
|
slog.Debug("Initial automatic upgrade", slogutil.Error(err))
|
||||||
} else {
|
} else {
|
||||||
slog.Info("Initial automatic upgrade", slogutil.Error(err))
|
slog.Info("Initial automatic upgrade", slogutil.Error(err))
|
||||||
@@ -721,7 +722,7 @@ func autoUpgrade(cfg config.Wrapper, app *syncthing.App, evLogger events.Logger)
|
|||||||
|
|
||||||
checkInterval := time.Duration(opts.AutoUpgradeIntervalH) * time.Hour
|
checkInterval := time.Duration(opts.AutoUpgradeIntervalH) * time.Hour
|
||||||
rel, err := upgrade.LatestRelease(opts.ReleasesURL, build.Version, opts.UpgradeToPreReleases)
|
rel, err := upgrade.LatestRelease(opts.ReleasesURL, build.Version, opts.UpgradeToPreReleases)
|
||||||
if err == upgrade.ErrUpgradeUnsupported {
|
if errors.Is(err, upgrade.ErrUpgradeUnsupported) {
|
||||||
sub.Unsubscribe()
|
sub.Unsubscribe()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -837,7 +838,8 @@ func setPauseState(cfgWrapper config.Wrapper, paused bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func exitCodeForUpgrade(err error) int {
|
func exitCodeForUpgrade(err error) int {
|
||||||
if _, ok := err.(*errNoUpgrade); ok {
|
var noUpgradeErr *errNoUpgrade
|
||||||
|
if errors.As(err, &noUpgradeErr) {
|
||||||
return svcutil.ExitNoUpgradeAvailable.AsInt()
|
return svcutil.ExitNoUpgradeAvailable.AsInt()
|
||||||
}
|
}
|
||||||
return svcutil.ExitError.AsInt()
|
return svcutil.ExitError.AsInt()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
@@ -176,7 +177,8 @@ func (c *serveCmd) monitorMain() {
|
|||||||
os.Exit(svcutil.ExitSuccess.AsInt())
|
os.Exit(svcutil.ExitSuccess.AsInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
if exiterr, ok := err.(*exec.ExitError); ok {
|
exiterr := &exec.ExitError{}
|
||||||
|
if errors.As(err, &exiterr) {
|
||||||
exitCode := exiterr.ExitCode()
|
exitCode := exiterr.ExitCode()
|
||||||
if stopped || c.NoRestart {
|
if stopped || c.NoRestart {
|
||||||
os.Exit(exitCode)
|
os.Exit(exitCode)
|
||||||
|
|||||||
+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.
|
// due to a config change through the API, let that finish successfully.
|
||||||
timeout, cancel := context.WithTimeout(context.Background(), s.shutdownTimeout)
|
timeout, cancel := context.WithTimeout(context.Background(), s.shutdownTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := srv.Shutdown(timeout); err == timeout.Err() {
|
if err := srv.Shutdown(timeout); errors.Is(err, timeout.Err()) {
|
||||||
srv.Close()
|
srv.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package beacon
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
@@ -93,7 +94,8 @@ func writeBroadcasts(ctx context.Context, inbox <-chan []byte, port int) error {
|
|||||||
_, err = conn.WriteTo(bs, dst)
|
_, err = conn.WriteTo(bs, dst)
|
||||||
conn.SetWriteDeadline(time.Time{})
|
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
|
// Write timeouts should not happen. We treat it as a fatal
|
||||||
// error on the socket.
|
// error on the socket.
|
||||||
l.Debugln(err)
|
l.Debugln(err)
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ func (f FolderConfiguration) ModTimeWindow() time.Duration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *FolderConfiguration) CreateMarker() error {
|
func (f *FolderConfiguration) CreateMarker() error {
|
||||||
if err := f.CheckPath(); err != ErrMarkerMissing {
|
if err := f.CheckPath(); !errors.Is(err, ErrMarkerMissing) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if f.MarkerName != DefaultMarkerName {
|
if f.MarkerName != DefaultMarkerName {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
package connections
|
package connections
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -20,7 +21,8 @@ func fixupPort(uri *url.URL, defaultPort int) *url.URL {
|
|||||||
copyURI := *uri
|
copyURI := *uri
|
||||||
|
|
||||||
host, port, err := net.SplitHostPort(uri.Host)
|
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]"
|
// addr is of the form "1.2.3.4" or "[fe80::1]"
|
||||||
host = uri.Host
|
host = uri.Host
|
||||||
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
|
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ func (c *rawConnection) readerLoop() {
|
|||||||
for {
|
for {
|
||||||
msg, err := c.readMessage(fourByteBuf)
|
msg, err := c.readMessage(fourByteBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == errUnknownMessage {
|
if errors.Is(err, errUnknownMessage) {
|
||||||
// Unknown message types are skipped, for future extensibility.
|
// Unknown message types are skipped, for future extensibility.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -144,7 +144,7 @@ func (p *Process) Stop() (*os.ProcessState, error) {
|
|||||||
default:
|
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
|
// Unexpected EOF is somewhat expected here, as we may exit before
|
||||||
// returning something sensible.
|
// returning something sensible.
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package client
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -137,7 +138,8 @@ func TestRelay(ctx context.Context, uri *url.URL, certs []tls.Certificate, sleep
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if _, ok := err.(*incorrectResponseCodeErr); !ok {
|
incorrectResponseCodeErr := &incorrectResponseCodeErr{}
|
||||||
|
if errors.As(err, &incorrectResponseCodeErr) {
|
||||||
return fmt.Errorf("getting invitation: %w", err)
|
return fmt.Errorf("getting invitation: %w", err)
|
||||||
}
|
}
|
||||||
time.Sleep(sleep)
|
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,
|
// 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.
|
// and pass it to the underlying handler, and let them deal with it.
|
||||||
if err == ErrIdentificationFailed {
|
if errors.Is(err, ErrIdentificationFailed) {
|
||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -229,7 +229,8 @@ USER-AGENT: syncthing/%s
|
|||||||
|
|
||||||
_, err = socket.WriteTo(search, &ssdp)
|
_, err = socket.WriteTo(search, &ssdp)
|
||||||
if err != nil {
|
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)
|
l.Debugln("UPnP discovery: sending search request:", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -101,8 +101,9 @@ func (v external) Archive(filePath string) error {
|
|||||||
combinedOutput, err := cmd.CombinedOutput()
|
combinedOutput, err := cmd.CombinedOutput()
|
||||||
l.Debugln("external command output:", string(combinedOutput))
|
l.Debugln("external command output:", string(combinedOutput))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if eerr, ok := err.(*exec.ExitError); ok && len(eerr.Stderr) > 0 {
|
eerr := &exec.ExitError{}
|
||||||
return fmt.Errorf("%v: %v", err, string(eerr.Stderr))
|
if errors.As(err, &eerr) && len(eerr.Stderr) > 0 {
|
||||||
|
return fmt.Errorf("%w: %v", err, string(eerr.Stderr))
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user