diff --git a/cmd/restic/cmd_self_update.go b/cmd/restic/cmd_self_update.go index c7a29ac86..f632b668b 100644 --- a/cmd/restic/cmd_self_update.go +++ b/cmd/restic/cmd_self_update.go @@ -60,12 +60,14 @@ func runSelfUpdate(opts SelfUpdateOptions, gopts GlobalOptions, args []string) e Printf("writing restic to %v\n", opts.Output) - v, err := selfupdate.DownloadLatestStableRelease(gopts.ctx, opts.Output, Verbosef) + v, err := selfupdate.DownloadLatestStableRelease(gopts.ctx, opts.Output, version, Verbosef) if err != nil { return errors.Fatalf("unable to update restic: %v", err) } - Printf("successfully updated restic to version %v\n", v) + if v != version { + Printf("successfully updated restic to version %v\n", v) + } return nil } diff --git a/internal/selfupdate/download.go b/internal/selfupdate/download.go index 5671dda8e..888007c4c 100644 --- a/internal/selfupdate/download.go +++ b/internal/selfupdate/download.go @@ -106,7 +106,7 @@ func extractToFile(buf []byte, filename, target string, printf func(string, ...i // DownloadLatestStableRelease downloads the latest stable released version of // restic and saves it to target. It returns the version string for the newest // version. The function printf is used to print progress information. -func DownloadLatestStableRelease(ctx context.Context, target string, printf func(string, ...interface{})) (version string, err error) { +func DownloadLatestStableRelease(ctx context.Context, target, currentVersion string, printf func(string, ...interface{})) (version string, err error) { if printf == nil { printf = func(string, ...interface{}) {} } @@ -118,6 +118,11 @@ func DownloadLatestStableRelease(ctx context.Context, target string, printf func return "", err } + if rel.Version == currentVersion { + printf("restic is up to date\n") + return currentVersion, nil + } + printf("latest version is %v\n", rel.Version) _, sha256sums, err := getGithubDataFile(ctx, rel.Assets, "SHA256SUMS", printf)