delete storage fix

pull/1/head
DiMartinoXBMC 2015-08-11 18:43:29 +03:00
parent 82dab260c8
commit e7693e5698
4 changed files with 19 additions and 15 deletions

View File

@ -55,9 +55,9 @@ class Core:
self.userStorageDirectory = os.path.join(download_dir, 'Torrenter') self.userStorageDirectory = os.path.join(download_dir, 'Torrenter')
def sectionMenu(self): def sectionMenu(self):
if self.__settings__.getSetting('plugin_name')!=self.__plugin__: if self.__settings__.getSetting('plugin_name') != self.__plugin__:
#Every update run #Every update run
self.__settings__.setSetting('plugin_name',self.__plugin__) self.__settings__.setSetting('plugin_name', self.__plugin__)
check_network_advancedsettings() check_network_advancedsettings()
check_download_dir() check_download_dir()
if self.__plugin__ == 'Torrenter v.2.3.7': if self.__plugin__ == 'Torrenter v.2.3.7':

View File

@ -278,7 +278,6 @@ class TorrentPlayer(xbmc.Player):
return return
xbmc.sleep(1000) xbmc.sleep(1000)
#self.torrent.torrentHandle.flush_cache() #self.torrent.torrentHandle.flush_cache()
self.torrent.resume_data()
self.torrent.session.remove_torrent(self.torrent.torrentHandle) self.torrent.session.remove_torrent(self.torrent.torrentHandle)
progressBar.update(0) progressBar.update(0)
progressBar.close() progressBar.close()

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.torrenter" name="Torrenter" version="2.3.7" provider-name="vadim.skorba, DiMartino"> <addon id="plugin.video.torrenter" name="Torrenter" version="2.3.8" provider-name="vadim.skorba, DiMartino">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.libtorrent"/> <import addon="script.module.libtorrent"/>

View File

@ -53,7 +53,9 @@ __plugin__ = __settings__.getAddonInfo('name') + " v." + __version__
def clearStorage(userStorageDirectory): def clearStorage(userStorageDirectory):
userStorageDirectory = decode(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 import shutil
temp = userStorageDirectory.rstrip('Torrenter').rstrip('/\\') temp = userStorageDirectory.rstrip('Torrenter').rstrip('/\\')
@ -86,13 +88,17 @@ def clearStorage(userStorageDirectory):
if saved_bool: if saved_bool:
shutil.move(saved_temp, saved) 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: try:
DownloadDB().clear() DownloadDB().clear()
except Exception, e: except Exception, e:
log('[clearStorage]: DownloadDB().clear() failed. '+str(e)) log('[clearStorage]: DownloadDB().clear() failed. '+str(e))
showMessage(Localization.localize('Storage'), Localization.localize('Storage was cleared'), forced=True)
def sortcomma(dict, json): def sortcomma(dict, json):
for x in dict: for x in dict:
@ -1322,11 +1328,10 @@ def fetchData(url, referer=None):
def file_decode(filename): def file_decode(filename):
pass pass
#if not __settings__.getSetting('delete_russian') == 'true': try:
# try: filename = filename.decode('utf-8') # ,'ignore')
# filename = filename.decode('utf-8') # ,'ignore') except:
# except: pass
# pass
return filename return filename
@ -1672,14 +1677,14 @@ def vista_check():
return platform.release() == "Vista" return platform.release() == "Vista"
def is_writable(path): def is_writable(path):
if not os.path.exists(path): if not xbmcvfs.exists(path+os.sep):
xbmcvfs.mkdirs(path) xbmcvfs.mkdirs(path)
try: try:
open(os.path.join(path, 'temp'), 'w') open(os.path.join(file_decode(path), 'temp'), 'w')
except: except:
return False return False
else: else:
os.remove(os.path.join(path, 'temp')) os.remove(os.path.join(file_decode(path), 'temp'))
return True return True
def unescape(string): def unescape(string):