From f71278138f317b4fec9629d644bc5c680706a441 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Thu, 18 Sep 2025 22:52:56 +0200 Subject: [PATCH] drop warnf --- cmd/restic/cleanup.go | 4 +++- cmd/restic/global.go | 9 --------- cmd/restic/main.go | 4 +++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cmd/restic/cleanup.go b/cmd/restic/cleanup.go index 45dc43b5c..b01029c0c 100644 --- a/cmd/restic/cleanup.go +++ b/cmd/restic/cleanup.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "os" "os/signal" "syscall" @@ -23,7 +24,8 @@ func createGlobalContext() context.Context { func cleanupHandler(c <-chan os.Signal, cancel context.CancelFunc) { s := <-c debug.Log("signal %v received, cleaning up", s) - Warnf("\rsignal %v received, cleaning up \n", s) + // ignore error as there's no good way to handle it + _, _ = fmt.Fprintf(os.Stderr, "\rsignal %v received, cleaning up \n", s) if val, _ := os.LookupEnv("RESTIC_DEBUG_STACKTRACE_SIGINT"); val != "" { _, _ = os.Stderr.WriteString("\n--- STACKTRACE START ---\n\n") diff --git a/cmd/restic/global.go b/cmd/restic/global.go index ca4a8b890..4478d589b 100644 --- a/cmd/restic/global.go +++ b/cmd/restic/global.go @@ -197,15 +197,6 @@ func collectBackends() *location.Registry { return backends } -// Warnf writes the message to the configured stderr stream. -func Warnf(format string, args ...interface{}) { - _, err := fmt.Fprintf(globalOptions.stderr, format, args...) - if err != nil { - fmt.Fprintf(os.Stderr, "unable to write to stderr: %v\n", err) - } - debug.Log(format, args...) -} - // resolvePassword determines the password to be used for opening the repository. func resolvePassword(opts *GlobalOptions, envStr string) (string, error) { if opts.PasswordFile != "" && opts.PasswordCommand != "" { diff --git a/cmd/restic/main.go b/cmd/restic/main.go index f4b17aa92..179fd1d0d 100644 --- a/cmd/restic/main.go +++ b/cmd/restic/main.go @@ -141,7 +141,9 @@ func printExitError(code int, message string) { err := json.NewEncoder(globalOptions.stderr).Encode(jsonS) if err != nil { - Warnf("JSON encode failed: %v\n", err) + // ignore error as there's no good way to handle it + _, _ = fmt.Fprintf(os.Stderr, "JSON encode failed: %v\n", err) + debug.Log("JSON encode failed: %v\n", err) return } } else {