Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
fixed GetFileContents() to surely return a non-nil error on Fail. (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
KojiNakamaru committed Jun 16, 2020
1 parent a5c371f commit 3c2bc80
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gdrive/gdrive.go
Expand Up @@ -1015,7 +1015,16 @@ func (gd *GDrive) GetFileContents(f *File) (io.ReadCloser, error) {
// Rate-limit the download, if required.
return makeLimitedDownloadReader(resp.Body), nil
case Fail:
return nil, err
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}
if err != nil {
return nil, err
} else if resp != nil {
return nil, fmt.Errorf("%s", resp.Status)
} else {
return nil, fmt.Errorf("unknown error")
}
case Retry:
}
}
Expand Down

0 comments on commit 3c2bc80

Please sign in to comment.