"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
bin/get-github-release.go: report body of HTTP responses with errors
Nick Craig-Wood2e7e15461bc1
diff --git a/bin/get-github-release.go b/bin/get-github-release.goindex 658161029..6b19f9b9d 100644--- a/bin/get-github-release.go+++ b/bin/get-github-release.go@@ -7,7 +7,9 @@ package mainimport ("encoding/json""flag"+ "fmt""io"+ "io/ioutil""log""net/http""os"@@ -129,6 +131,15 @@ func defaultBinDir() string {return binDir}+// read the body or an error message+func readBody(in io.Reader) string {+ data, err := ioutil.ReadAll(in)+ if err != nil {+ return fmt.Sprintf("Error reading body: %v", err.Error())+ }+ return string(data)+}+// Get an asset URL and namefunc getAsset(project string, matchName *regexp.Regexp) (string, string) {url := "https://api.github.com/repos/" + project + "/releases/latest"@@ -138,6 +149,7 @@ func getAsset(project string, matchName *regexp.Regexp) (string, string) {log.Fatalf("Failed to fetch release info %q: %v", url, err)}if resp.StatusCode != http.StatusOK {+ log.Printf("Error: %s", readBody(resp.Body))log.Fatalf("Bad status %d when fetching %q release info: %s", resp.StatusCode, url, resp.Status)}var release Release@@ -173,6 +185,7 @@ func getFile(url, fileName string) {log.Fatalf("Failed to fetch asset %q: %v", url, err)}if resp.StatusCode != http.StatusOK {+ log.Printf("Error: %s", readBody(resp.Body))log.Fatalf("Bad status %d when fetching %q asset: %s", resp.StatusCode, url, resp.Status)}