From 2aa4234efa6e04fdeee3129acdaa3464aa170dcd Mon Sep 17 00:00:00 2001 From: Oskari Saarenmaa Date: Tue, 14 Feb 2017 21:52:26 +0200 Subject: auth/file_source: don't try to read non-existent files Commit b33b3e96e introduced a bug where we try to read a token file even if it doesn't exist, causing unauthenticated run (e.g. `gdrive about`) to fail with the error Failed getting oauth client: Failed to read token: unexpected end of JSON input Closes #257. --- auth/file_source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/file_source.go b/auth/file_source.go index 11e7325..9223d1d 100644 --- a/auth/file_source.go +++ b/auth/file_source.go @@ -47,7 +47,7 @@ func ReadFile(path string) ([]byte, bool, error) { func ReadToken(path string) (*oauth2.Token, bool, error) { content, exists, err := ReadFile(path) - if err != nil { + if err != nil || exists == false { return nil, exists, err } -- cgit v1.2.3