aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOskari Saarenmaa2017-02-14 21:52:26 +0200
committerOskari Saarenmaa2017-02-15 00:14:54 +0200
commit2aa4234efa6e04fdeee3129acdaa3464aa170dcd (patch)
tree9e53427d0ff6510843d5b53efe9d0aa893235de6
parentc7ad97798acefc2f801393d5bf59876386954f46 (diff)
downloadgdrive-2aa4234efa6e04fdeee3129acdaa3464aa170dcd.tar.bz2
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.
-rw-r--r--auth/file_source.go2
1 files changed, 1 insertions, 1 deletions
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
}