An error is returned if caused by client policy (such as CheckRedirect), or failure to speak HTTP (such as a network connectivity problem). A non-2xx status code doesn't cause an error.
func downloadDriveFile(writer io.Writer, driveFile *gdrive.File) however supposes contentReader is non-nil if err is nil
func (gd *GDrive) GetFileContents(f *File) (io.ReadCloser, error)
may returnnil, nil
onFail:
,https://github.com/google/skicka/blob/a5c371fe953182b69bfd44c14297c1686382cbda/gdrive/gdrive.go#L1011-L1020 https://github.com/google/skicka/blob/a5c371fe953182b69bfd44c14297c1686382cbda/gdrive/http.go#L54-L60
as
gd.client.Do(request)
doesn't cause an error for non-2xx status code.cf. https://golang.org/pkg/net/http/#Client.Do
func downloadDriveFile(writer io.Writer, driveFile *gdrive.File)
however supposescontentReader
is non-nil iferr
is nilhttps://github.com/google/skicka/blob/a5c371fe953182b69bfd44c14297c1686382cbda/download.go#L549-L564
and may cause a panic as below:
This patch adjusts GetFileContents() to always return a non-nil error on
Fail:
.