From 17ffb0855fd261c8bd45db5c23683bff7d8c310d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 25 Jul 2014 18:19:49 +0100 Subject: [PATCH] Fixes after running errcheck --- drive/drive.go | 2 +- dropbox/dropbox.go | 5 ++--- fs/operations.go | 14 ++++++++------ googlecloudstorage/googlecloudstorage.go | 2 +- local/local.go | 7 +++++-- rclone.go | 6 +++++- 6 files changed, 22 insertions(+), 14 deletions(-) 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() } }