"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
rc/webgui: improve error handling on web fetches
Nick Craig-Wood9c01ac9894ad
diff --git a/fs/rc/webgui/webgui.go b/fs/rc/webgui/webgui.goindex b794af468..7e73cabed 100644--- a/fs/rc/webgui/webgui.go+++ b/fs/rc/webgui/webgui.go@@ -15,19 +15,23 @@ import ("strings""time"+ "github.com/pkg/errors""github.com/rclone/rclone/fs"- "github.com/rclone/rclone/lib/errors")// GetLatestReleaseURL returns the latest release details of the rclone-webui-reactfunc GetLatestReleaseURL(fetchURL string) (string, string, int, error) {resp, err := http.Get(fetchURL)if err != nil {- return "", "", 0, errors.New("Error getting latest release of rclone-webui")+ return "", "", 0, errors.Wrap(err, "failed getting latest release of rclone-webui")+ }+ defer fs.CheckClose(resp.Body, &err)+ if resp.StatusCode != http.StatusOK {+ return "", "", 0, errors.Errorf("bad HTTP status %d (%s) when fetching %s", resp.StatusCode, resp.Status, fetchURL)}results := gitHubRequest{}if err := json.NewDecoder(resp.Body).Decode(&results); err != nil {- return "", "", 0, errors.New("could not decode results from http request")+ return "", "", 0, errors.Wrap(err, "could not decode results from http request")}if len(results.Assets) < 1 {return "", "", 0, errors.New("could not find an asset in the release. " +@@ -124,14 +128,16 @@ func CheckAndDownloadWebGUIRelease(checkUpdate bool, forceUpdate bool, fetchURL}// DownloadFile is a helper function to download a file from url to the filepath-func DownloadFile(filepath string, url string) error {-+func DownloadFile(filepath string, url string) (err error) {// Get the dataresp, err := http.Get(url)if err != nil {return err}defer fs.CheckClose(resp.Body, &err)+ if resp.StatusCode != http.StatusOK {+ return errors.Errorf("bad HTTP status %d (%s) when fetching %s", resp.StatusCode, resp.Status, url)+ }// Create the fileout, err := os.Create(filepath)