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

Fixes after running errcheck

Nick Craig-Wood17ffb0855fd2
diff --git a/drive/drive.go b/drive/drive.go
index f04efd469..d5166f96c 100644
--- a/drive/drive.go
+++ b/drive/drive.go
@@ -840,7 +840,7 @@ func (o *FsObjectDrive) Open() (in io.ReadCloser, err error) {
return nil, err
}
if res.StatusCode != 200 {
- res.Body.Close()
+ _ = res.Body.Close() // ignore error
return nil, fmt.Errorf("Bad response: %d: %s", res.StatusCode, res.Status)
}
return res.Body, nil
diff --git a/dropbox/dropbox.go b/dropbox/dropbox.go
index f5ec62624..c4c9b32c3 100644
--- a/dropbox/dropbox.go
+++ b/dropbox/dropbox.go
@@ -574,7 +574,7 @@ func metadataKey(path string) string {
// NB File system is case insensitive
path = strings.ToLower(path)
hash := md5.New()
- hash.Write([]byte(path))
+ _, _ = hash.Write([]byte(path))
return fmt.Sprintf("%x", hash.Sum(nil))
}
@@ -635,8 +635,7 @@ func (o *FsObjectDropbox) readMetaData() (err error) {
}
// Last resort
- o.readEntryAndSetMetadata()
- return nil
+ return o.readEntryAndSetMetadata()
}
// ModTime returns the modification time of the object
diff --git a/fs/operations.go b/fs/operations.go
index 28bed028b..ab78a7654 100644
--- a/fs/operations.go
+++ b/fs/operations.go
@@ -504,19 +504,21 @@ func Rmdir(f Fs) error {
//
// FIXME doesn't delete local directories
func Purge(f Fs) error {
+ var err error
if purger, ok := f.(Purger); ok {
if Config.DryRun {
Debug(f, "Not purging as --dry-run set")
} else {
- err := purger.Purge()
- if err != nil {
- Stats.Error()
- return err
- }
+ err = purger.Purge()
}
} else {
+ // DeleteFiles and Rmdir observe --dry-run
DeleteFiles(f.List())
- Rmdir(f)
+ err = Rmdir(f)
+ }
+ if err != nil {
+ Stats.Error()
+ return err
}
return nil
}
diff --git a/googlecloudstorage/googlecloudstorage.go b/googlecloudstorage/googlecloudstorage.go
index 83dcc5184..d08fdc66d 100644
--- a/googlecloudstorage/googlecloudstorage.go
+++ b/googlecloudstorage/googlecloudstorage.go
@@ -530,7 +530,7 @@ func (o *FsObjectStorage) Open() (in io.ReadCloser, err error) {
return nil, err
}
if res.StatusCode != 200 {
- res.Body.Close()
+ _ = res.Body.Close() // ignore error
return nil, fmt.Errorf("Bad response: %d: %s", res.StatusCode, res.Status)
}
return res.Body, nil
diff --git a/local/local.go b/local/local.go
index ecdd8b9f2..0b48889c0 100644
--- a/local/local.go
+++ b/local/local.go
@@ -217,12 +217,15 @@ func (f *FsLocal) readPrecision() (precision time.Duration) {
}
path := fd.Name()
// fmt.Println("Created temp file", path)
- fd.Close()
+ err = fd.Close()
+ if err != nil {
+ return time.Second
+ }
// Delete it on return
defer func() {
// fmt.Println("Remove temp file")
- os.Remove(path)
+ _ = os.Remove(path) // ignore error
}()
// Find the minimum duration we can detect
diff --git a/rclone.go b/rclone.go
index 48eb08291..9b290861d 100644
--- a/rclone.go
+++ b/rclone.go
@@ -265,7 +265,11 @@ func ParseFlags() {
fs.Stats.Error()
log.Fatal(err)
}
- pprof.StartCPUProfile(f)
+ err = pprof.StartCPUProfile(f)
+ if err != nil {
+ fs.Stats.Error()
+ log.Fatal(err)
+ }
defer pprof.StopCPUProfile()
}
}