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 return nil, err
} }
if res.StatusCode != 200 { 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 nil, fmt.Errorf("Bad response: %d: %s", res.StatusCode, res.Status)
} }
return res.Body, nil return res.Body, nil

View file

@ -574,7 +574,7 @@ func metadataKey(path string) string {
// NB File system is case insensitive // NB File system is case insensitive
path = strings.ToLower(path) path = strings.ToLower(path)
hash := md5.New() hash := md5.New()
hash.Write([]byte(path)) _, _ = hash.Write([]byte(path))
return fmt.Sprintf("%x", hash.Sum(nil)) return fmt.Sprintf("%x", hash.Sum(nil))
} }
@ -635,8 +635,7 @@ func (o *FsObjectDropbox) readMetaData() (err error) {
} }
// Last resort // Last resort
o.readEntryAndSetMetadata() return o.readEntryAndSetMetadata()
return nil
} }
// ModTime returns the modification time of the object // 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 // FIXME doesn't delete local directories
func Purge(f Fs) error { func Purge(f Fs) error {
var err error
if purger, ok := f.(Purger); ok { if purger, ok := f.(Purger); ok {
if Config.DryRun { if Config.DryRun {
Debug(f, "Not purging as --dry-run set") Debug(f, "Not purging as --dry-run set")
} else { } else {
err := purger.Purge() err = purger.Purge()
}
} else {
// DeleteFiles and Rmdir observe --dry-run
DeleteFiles(f.List())
err = Rmdir(f)
}
if err != nil { if err != nil {
Stats.Error() Stats.Error()
return err return err
} }
}
} else {
DeleteFiles(f.List())
Rmdir(f)
}
return nil return nil
} }

View file

@ -530,7 +530,7 @@ func (o *FsObjectStorage) Open() (in io.ReadCloser, err error) {
return nil, err return nil, err
} }
if res.StatusCode != 200 { 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 nil, fmt.Errorf("Bad response: %d: %s", res.StatusCode, res.Status)
} }
return res.Body, nil return res.Body, nil

View file

@ -217,12 +217,15 @@ func (f *FsLocal) readPrecision() (precision time.Duration) {
} }
path := fd.Name() path := fd.Name()
// fmt.Println("Created temp file", path) // fmt.Println("Created temp file", path)
fd.Close() err = fd.Close()
if err != nil {
return time.Second
}
// Delete it on return // Delete it on return
defer func() { defer func() {
// fmt.Println("Remove temp file") // fmt.Println("Remove temp file")
os.Remove(path) _ = os.Remove(path) // ignore error
}() }()
// Find the minimum duration we can detect // Find the minimum duration we can detect

View file

@ -265,7 +265,11 @@ func ParseFlags() {
fs.Stats.Error() fs.Stats.Error()
log.Fatal(err) log.Fatal(err)
} }
pprof.StartCPUProfile(f) err = pprof.StartCPUProfile(f)
if err != nil {
fs.Stats.Error()
log.Fatal(err)
}
defer pprof.StopCPUProfile() defer pprof.StopCPUProfile()
} }
} }