Procházet zdrojové kódy

all: Use own automaxprocs package that doesn't log (ref #9436) (#9437)

### Purpose

🤫
Jakob Borg před 1 rokem
rodič
revize
07a9fa2dbd

+ 1 - 1
build.go

@@ -33,8 +33,8 @@ import (
 	"text/template"
 	"time"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	buildpkg "github.com/syncthing/syncthing/lib/build"
-	_ "go.uber.org/automaxprocs"
 )
 
 var (

+ 1 - 1
cmd/stcompdirs/main.go

@@ -15,8 +15,8 @@ import (
 	"os"
 	"path/filepath"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/sha256"
-	_ "go.uber.org/automaxprocs"
 )
 
 func main() {

+ 1 - 1
cmd/stcrashreceiver/main.go

@@ -25,9 +25,9 @@ import (
 	"github.com/alecthomas/kong"
 	raven "github.com/getsentry/raven-go"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/sha256"
 	"github.com/syncthing/syncthing/lib/ur"
-	_ "go.uber.org/automaxprocs"
 )
 
 const maxRequestSize = 1 << 20 // 1 MiB

+ 1 - 1
cmd/stdisco/main.go

@@ -15,10 +15,10 @@ import (
 	"strings"
 	"time"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/beacon"
 	"github.com/syncthing/syncthing/lib/discover"
 	"github.com/syncthing/syncthing/lib/protocol"
-	_ "go.uber.org/automaxprocs"
 )
 
 var (

+ 1 - 1
cmd/stdiscosrv/main.go

@@ -19,12 +19,12 @@ import (
 	"time"
 
 	"github.com/prometheus/client_golang/prometheus/promhttp"
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/build"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/tlsutil"
 	"github.com/syndtr/goleveldb/leveldb/opt"
 	"github.com/thejerf/suture/v4"
-	_ "go.uber.org/automaxprocs"
 )
 
 const (

+ 1 - 1
cmd/stevents/main.go

@@ -15,7 +15,7 @@ import (
 	"os"
 	"time"
 
-	_ "go.uber.org/automaxprocs"
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 )
 
 type event struct {

+ 1 - 1
cmd/stfileinfo/main.go

@@ -13,9 +13,9 @@ import (
 	"os"
 	"path/filepath"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/scanner"
-	_ "go.uber.org/automaxprocs"
 )
 
 func main() {

+ 1 - 1
cmd/stfinddevice/main.go

@@ -16,11 +16,11 @@ import (
 	"os"
 	"time"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/discover"
 	"github.com/syncthing/syncthing/lib/events"
 	"github.com/syncthing/syncthing/lib/protocol"
-	_ "go.uber.org/automaxprocs"
 )
 
 var timeout = 5 * time.Second

+ 1 - 1
cmd/stfindignored/main.go

@@ -12,9 +12,9 @@ import (
 	"fmt"
 	"os"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/fs"
 	"github.com/syncthing/syncthing/lib/ignore"
-	_ "go.uber.org/automaxprocs"
 )
 
 func main() {

+ 3 - 3
cmd/stgenfiles/main.go

@@ -16,7 +16,7 @@ import (
 	"path/filepath"
 	"time"
 
-	_ "go.uber.org/automaxprocs"
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 )
 
 func main() {
@@ -45,7 +45,7 @@ func generateFiles(dir string, files, maxexp int, srcname string) error {
 		}
 
 		p0 := filepath.Join(dir, string(n[0]), n[0:2])
-		err = os.MkdirAll(p0, 0755)
+		err = os.MkdirAll(p0, 0o755)
 		if err != nil {
 			log.Fatal(err)
 		}
@@ -84,7 +84,7 @@ func generateOneFile(fd io.ReadSeeker, p1 string, s int64) error {
 		return err
 	}
 
-	os.Chmod(p1, os.FileMode(rand.Intn(0777)|0400))
+	os.Chmod(p1, os.FileMode(rand.Intn(0o777)|0o400))
 
 	t := time.Now().Add(-time.Duration(rand.Intn(30*86400)) * time.Second)
 	return os.Chtimes(p1, t, t)

+ 1 - 1
cmd/strelaypoolsrv/main.go

@@ -26,13 +26,13 @@ import (
 	"github.com/prometheus/client_golang/prometheus/promhttp"
 	"github.com/syncthing/syncthing/cmd/strelaypoolsrv/auto"
 	"github.com/syncthing/syncthing/lib/assets"
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/httpcache"
 	"github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/rand"
 	"github.com/syncthing/syncthing/lib/relay/client"
 	"github.com/syncthing/syncthing/lib/sync"
 	"github.com/syncthing/syncthing/lib/tlsutil"
-	_ "go.uber.org/automaxprocs"
 )
 
 type location struct {

+ 1 - 1
cmd/strelaysrv/main.go

@@ -19,6 +19,7 @@ import (
 	"syscall"
 	"time"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/build"
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/events"
@@ -29,7 +30,6 @@ import (
 	"github.com/syncthing/syncthing/lib/relay/protocol"
 	"github.com/syncthing/syncthing/lib/tlsutil"
 	_ "github.com/syncthing/syncthing/lib/upnp"
-	_ "go.uber.org/automaxprocs"
 	"golang.org/x/time/rate"
 )
 

+ 1 - 1
cmd/strelaysrv/testutil/main.go

@@ -14,10 +14,10 @@ import (
 	"path/filepath"
 	"time"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	syncthingprotocol "github.com/syncthing/syncthing/lib/protocol"
 	"github.com/syncthing/syncthing/lib/relay/client"
 	"github.com/syncthing/syncthing/lib/relay/protocol"
-	_ "go.uber.org/automaxprocs"
 )
 
 func main() {

+ 1 - 1
cmd/stsigtool/main.go

@@ -12,9 +12,9 @@ import (
 	"log"
 	"os"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/signature"
 	"github.com/syncthing/syncthing/lib/upgrade"
-	_ "go.uber.org/automaxprocs"
 )
 
 func main() {

+ 1 - 1
cmd/stupgrades/main.go

@@ -19,9 +19,9 @@ import (
 	"time"
 
 	"github.com/alecthomas/kong"
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/httpcache"
 	"github.com/syncthing/syncthing/lib/upgrade"
-	_ "go.uber.org/automaxprocs"
 )
 
 type cli struct {

+ 2 - 2
cmd/stvanity/main.go

@@ -26,8 +26,8 @@ import (
 	"sync/atomic"
 	"time"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/protocol"
-	_ "go.uber.org/automaxprocs"
 )
 
 type result struct {
@@ -158,7 +158,7 @@ func saveCert(priv interface{}, derBytes []byte) {
 		os.Exit(1)
 	}
 
-	keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
+	keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600)
 	if err != nil {
 		fmt.Println(err)
 		os.Exit(1)

+ 1 - 1
cmd/stwatchfile/main.go

@@ -13,8 +13,8 @@ import (
 	"os"
 	"time"
 
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/syncthing/syncthing/lib/sha256"
-	_ "go.uber.org/automaxprocs"
 )
 
 func main() {

+ 1 - 1
cmd/syncthing/main.go

@@ -30,9 +30,9 @@ import (
 	"time"
 
 	"github.com/alecthomas/kong"
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 	"github.com/thejerf/suture/v4"
 	"github.com/willabides/kongplete"
-	_ "go.uber.org/automaxprocs"
 
 	"github.com/syncthing/syncthing/cmd/syncthing/cli"
 	"github.com/syncthing/syncthing/cmd/syncthing/cmdutil"

+ 1 - 1
cmd/ursrv/main.go

@@ -13,7 +13,7 @@ import (
 	"github.com/alecthomas/kong"
 	"github.com/syncthing/syncthing/cmd/ursrv/aggregate"
 	"github.com/syncthing/syncthing/cmd/ursrv/serve"
-	_ "go.uber.org/automaxprocs"
+	_ "github.com/syncthing/syncthing/lib/automaxprocs"
 )
 
 type CLI struct {

+ 15 - 0
lib/automaxprocs/automaxprocs.go

@@ -0,0 +1,15 @@
+// Copyright (C) 2024 The Syncthing Authors.
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this file,
+// You can obtain one at https://mozilla.org/MPL/2.0/.
+
+package automaxprocs
+
+import (
+	"go.uber.org/automaxprocs/maxprocs"
+)
+
+func init() {
+	maxprocs.Set()
+}