Skip to content

Commit

Permalink
clean temp folders properly, we have seen some issues with folders th…
Browse files Browse the repository at this point in the history
…at couldn't be cleaned.
  • Loading branch information
amet committed May 23, 2012
1 parent dd8eda2 commit 2c8931c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
12 changes: 4 additions & 8 deletions script.xbmc.subtitles/resources/lib/gui.py
Expand Up @@ -6,7 +6,6 @@
import xbmc
import urllib
import socket
import xbmcvfs
import xbmcgui
import unicodedata

Expand Down Expand Up @@ -402,13 +401,10 @@ def Extract_Subtitles( self, zip_subs, subtitle_lang, gui = True ):
self.show_service_list(gui)

def clean_temp( self ):
dirs = [self.stream_sub_dir,self.tmp_sub_dir]
for temp_dir in dirs:
if not xbmcvfs.exists(temp_dir):
os.makedirs(temp_dir)
else:
rem_files(temp_dir)

for temp_dir in [self.stream_sub_dir,self.tmp_sub_dir]:
rem_files(temp_dir)


def show_service_list(self,gui):
try:
select_index = self.service_list.index(self.service)
Expand Down
14 changes: 6 additions & 8 deletions script.xbmc.subtitles/resources/lib/utilities.py
Expand Up @@ -6,6 +6,7 @@
import xbmc
import xbmcvfs
import xbmcgui
import shutil

_ = sys.modules[ "__main__" ].__language__
__scriptname__ = sys.modules[ "__main__" ].__scriptname__
Expand Down Expand Up @@ -166,14 +167,11 @@ def unpause():
xbmc.Player().pause()

def rem_files(directory):
try:
for root, dirs, files in os.walk(directory, topdown=False):
for items in dirs:
xbmcvfs.rmdir(os.path.join(root.encode("utf-8"), items.encode("utf-8")))
for name in files:
xbmcvfs.delete(os.path.join(root.encode("utf-8"), name.encode("utf-8")))
except:
pass
if xbmcvfs.exists(directory):
shutil.rmtree(directory)
xbmcvfs.mkdir(directory)



def copy_files( subtitle_file, file_path ):
subtitle_set = False
Expand Down

0 comments on commit 2c8931c

Please sign in to comment.