Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

selfupdate: obey --no-check-certificate flag

Nick Craig-Wood4471e6f258f5
diff --git a/cmd/selfupdate/selfupdate.go b/cmd/selfupdate/selfupdate.go
index 184710cb3..6da348050 100644
--- a/cmd/selfupdate/selfupdate.go
+++ b/cmd/selfupdate/selfupdate.go
@@ -68,13 +68,14 @@ var cmdSelfUpdate = &cobra.Command{
"versionIntroduced": "v1.55",
},
Run: func(command *cobra.Command, args []string) {
+ ctx := context.Background()
cmd.CheckArgs(0, 0, command, args)
if Opt.Package == "" {
Opt.Package = "zip"
}
gotActionFlags := Opt.Stable || Opt.Beta || Opt.Output != "" || Opt.Version != "" || Opt.Package != "zip"
if Opt.Check && !gotActionFlags {
- versionCmd.CheckVersion()
+ versionCmd.CheckVersion(ctx)
return
}
if Opt.Package != "zip" {
@@ -108,7 +109,7 @@ func GetVersion(ctx context.Context, beta bool, version string) (newVersion, sit
if version == "" {
// Request the latest release number from the download site
- _, newVersion, _, err = versionCmd.GetVersion(siteURL + "/version.txt")
+ _, newVersion, _, err = versionCmd.GetVersion(ctx, siteURL+"/version.txt")
return
}
diff --git a/cmd/version/version.go b/cmd/version/version.go
index 5d35cb98c..df8ac271e 100644
--- a/cmd/version/version.go
+++ b/cmd/version/version.go
@@ -2,6 +2,7 @@
package version
import (
+ "context"
"errors"
"fmt"
"io"
@@ -13,6 +14,7 @@ import (
"github.com/rclone/rclone/cmd"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/config/flags"
+ "github.com/rclone/rclone/fs/fshttp"
"github.com/spf13/cobra"
)
@@ -71,9 +73,10 @@ Or
"versionIntroduced": "v1.33",
},
Run: func(command *cobra.Command, args []string) {
+ ctx := context.Background()
cmd.CheckArgs(0, 0, command, args)
if check {
- CheckVersion()
+ CheckVersion(ctx)
} else {
cmd.ShowVersion()
}
@@ -89,8 +92,8 @@ func stripV(s string) string {
}
// GetVersion gets the version available for download
-func GetVersion(url string) (v *semver.Version, vs string, date time.Time, err error) {
- resp, err := http.Get(url)
+func GetVersion(ctx context.Context, url string) (v *semver.Version, vs string, date time.Time, err error) {
+ resp, err := fshttp.NewClient(ctx).Get(url)
if err != nil {
return v, vs, date, err
}
@@ -114,7 +117,7 @@ func GetVersion(url string) (v *semver.Version, vs string, date time.Time, err e
}
// CheckVersion checks the installed version against available downloads
-func CheckVersion() {
+func CheckVersion(ctx context.Context) {
vCurrent, err := semver.NewVersion(stripV(fs.Version))
if err != nil {
fs.Errorf(nil, "Failed to parse version: %v", err)
@@ -122,7 +125,7 @@ func CheckVersion() {
const timeFormat = "2006-01-02"
printVersion := func(what, url string) {
- v, vs, t, err := GetVersion(url + "version.txt")
+ v, vs, t, err := GetVersion(ctx, url+"version.txt")
if err != nil {
fs.Errorf(nil, "Failed to get rclone %s version: %v", what, err)
return