Fixes after running errcheck

This commit is contained in:
Nick Craig-Wood 2014-07-25 18:19:49 +01:00
parent 125fc8f1f0
commit 17ffb0855f
6 changed files with 22 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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()
}
}