From 46cd3c673171bebfc7abb64fd147b7ae851ff29c Mon Sep 17 00:00:00 2001 From: Rob Weber Date: Thu, 13 Dec 2012 14:18:14 -0600 Subject: [PATCH] remove token file if Dropbox authorization revoked --- changelog.txt | 2 ++ resources/lib/vfs.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index ad8af4f..68c22b6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,8 @@ Version 0.3.1 added try/except for multiple character encodings +remove token.txt file if Dropbox Authorization is revoked + Version 0.3.0 major vfs rewrite diff --git a/resources/lib/vfs.py b/resources/lib/vfs.py index 059e53f..ea6b7cf 100644 --- a/resources/lib/vfs.py +++ b/resources/lib/vfs.py @@ -84,7 +84,13 @@ class DropboxFileSystem(Vfs): sess.set_token(user_token_key,user_token_secret) self.client = client.DropboxClient(sess) - utils.log(str(self.client.account_info())) + + try: + utils.log(str(self.client.account_info())) + except: + #this didn't work, delete the token file + self.deleteToken() + def listdir(self,directory): if(self.client != None and self.exists(directory)): @@ -150,6 +156,7 @@ class DropboxFileSystem(Vfs): out.close() else: return False + def setToken(self,key,secret): #write the token files token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"),'w') @@ -166,6 +173,10 @@ class DropboxFileSystem(Vfs): return [key,secret] else: return ["",""] + + def deleteToken(self): + if(xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "tokens.txt"))): + xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "tokens.txt"))