From e7693e56980c73994562fc72f42f7ff4ec7bea76 Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Tue, 11 Aug 2015 18:43:29 +0300 Subject: [PATCH] delete storage fix --- Core.py | 4 ++-- Player.py | 1 - addon.xml | 2 +- functions.py | 27 ++++++++++++++++----------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Core.py b/Core.py index afda5b7..7a2d964 100644 --- a/Core.py +++ b/Core.py @@ -55,9 +55,9 @@ class Core: self.userStorageDirectory = os.path.join(download_dir, 'Torrenter') def sectionMenu(self): - if self.__settings__.getSetting('plugin_name')!=self.__plugin__: + if self.__settings__.getSetting('plugin_name') != self.__plugin__: #Every update run - self.__settings__.setSetting('plugin_name',self.__plugin__) + self.__settings__.setSetting('plugin_name', self.__plugin__) check_network_advancedsettings() check_download_dir() if self.__plugin__ == 'Torrenter v.2.3.7': diff --git a/Player.py b/Player.py index ad45e35..78ed3a3 100644 --- a/Player.py +++ b/Player.py @@ -278,7 +278,6 @@ class TorrentPlayer(xbmc.Player): return xbmc.sleep(1000) #self.torrent.torrentHandle.flush_cache() - self.torrent.resume_data() self.torrent.session.remove_torrent(self.torrent.torrentHandle) progressBar.update(0) progressBar.close() diff --git a/addon.xml b/addon.xml index 5b5c8ce..e9a80be 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@  - + diff --git a/functions.py b/functions.py index 25513a4..d534fa4 100644 --- a/functions.py +++ b/functions.py @@ -53,7 +53,9 @@ __plugin__ = __settings__.getAddonInfo('name') + " v." + __version__ def clearStorage(userStorageDirectory): userStorageDirectory = decode(userStorageDirectory) - if xbmcvfs.exists(userStorageDirectory + os.sep): + #log('[clearStorage]: storage '+str(userStorageDirectory) + os.sep) + if xbmcvfs.exists(userStorageDirectory + os.sep) or os.path.exists(userStorageDirectory): + log('[clearStorage]: storage exists') import shutil temp = userStorageDirectory.rstrip('Torrenter').rstrip('/\\') @@ -86,13 +88,17 @@ def clearStorage(userStorageDirectory): if saved_bool: shutil.move(saved_temp, saved) + showMessage(Localization.localize('Storage'), Localization.localize('Storage was cleared'), forced=True) + + else: + showMessage(Localization.localize('Storage'), Localization.localize('Does not exists'), forced=True) + log('[clearStorage]: fail storage '+userStorageDirectory + os.sep) + try: DownloadDB().clear() except Exception, e: log('[clearStorage]: DownloadDB().clear() failed. '+str(e)) - showMessage(Localization.localize('Storage'), Localization.localize('Storage was cleared'), forced=True) - def sortcomma(dict, json): for x in dict: @@ -1322,11 +1328,10 @@ def fetchData(url, referer=None): def file_decode(filename): pass - #if not __settings__.getSetting('delete_russian') == 'true': - # try: - # filename = filename.decode('utf-8') # ,'ignore') - # except: - # pass + try: + filename = filename.decode('utf-8') # ,'ignore') + except: + pass return filename @@ -1672,14 +1677,14 @@ def vista_check(): return platform.release() == "Vista" def is_writable(path): - if not os.path.exists(path): + if not xbmcvfs.exists(path+os.sep): xbmcvfs.mkdirs(path) try: - open(os.path.join(path, 'temp'), 'w') + open(os.path.join(file_decode(path), 'temp'), 'w') except: return False else: - os.remove(os.path.join(path, 'temp')) + os.remove(os.path.join(file_decode(path), 'temp')) return True def unescape(string):