From a522077521e75d75df2c196442c82bafa61f4344 Mon Sep 17 00:00:00 2001 From: Tim Crone Date: Wed, 18 Nov 2020 16:45:14 -0500 Subject: [PATCH] Ignore error if cache file doesn't exist (#16) --- gdrivefs/core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gdrivefs/core.py b/gdrivefs/core.py index 03a5121..5500392 100644 --- a/gdrivefs/core.py +++ b/gdrivefs/core.py @@ -53,7 +53,7 @@ def __init__(self, root_file_id=None, token="browser", :param token: str One of "anon", "browser", "cache". Using "browser" will prompt a URL to be put in a browser, and cache the response for future use with token="cache". - "browser" remove any previously cached value. + "browser" will remove any previously cached token file if it exists. :param access: str One of "full_control", "read_only :param spaces: @@ -85,7 +85,10 @@ def connect(self, method=None): self.service = srv.files() def _connect_browser(self): - os.remove(pydata_google_auth.cache.READ_WRITE._path) + try: + os.remove(pydata_google_auth.cache.READ_WRITE._path) + except OSError: + pass return self._connect_cache() def _connect_cache(self):