diff --git a/addon.xml b/addon.xml index d365d88..0324fd0 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + diff --git a/changelog.txt b/changelog.txt index 0de9134..897eb51 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +0.9.4 (2016-03-09): +* Directory removal fix alternate file method +* Added error handlers for alternate file method operations + 0.9.3 (2016-03-08): * Delete or move all files matching video filename minus the extension. diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index c4e93e4..dbe7132 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -86,4 +86,8 @@ No internet connection Canceled due to quantity of files You do not have permissions to move/delete this file + Error creating folder + Error removing folder + Error removing file + Error copying diff --git a/resources/lib/utilfile.py b/resources/lib/utilfile.py index 12ed26e..954e7fa 100644 --- a/resources/lib/utilfile.py +++ b/resources/lib/utilfile.py @@ -81,36 +81,42 @@ def __delete_files(source, match, del_empty): def __copy_directory_alt(source, destination): destination = os.path.join(destination, os.path.basename(source)) - xbmcvfs.mkdirs(destination) # todo error if exists? + if not xbmcvfs.mkdirs(destination): + raise ValueError('xbmcvfs.mkdirs', destination) dirs, files = xbmcvfs.listdir(source) for f in files: src = os.path.join(source, f) dest = os.path.join(destination, f) - xbmcvfs.copy(src, dest) + if not xbmcvfs.copy(src, dest): + raise ValueError('xbmcvfs.copy', src, dest) for d in dirs: d = os.path.join(source, d) __copy_directory(d, destination) def __copy_files_alt(source, destination, match): # create directories if needed - xbmcvfs.mkdirs(destination) + if not xbmcvfs.mkdirs(destination): + raise ValueError('xbmcvfs.mkdirs', destination) # move files from source to destination if match dirs, files = xbmcvfs.listdir(source) for f in files: if os.path.splitext(f)[0].startswith(match): src = os.path.join(source, f) dest = os.path.join(destination, f) - xbmcvfs.copy(src, dest) # todo error + if not xbmcvfs.copy(src, dest): + raise ValueError('xbmcvfs.copy', src, dest) def __delete_directory_alt(source): dirs, files = xbmcvfs.listdir(source) for d in dirs: d = os.path.join(source, d) - __delete_directory(d) + if not xbmcvfs.rmdir(d): + raise ValueError('xbmcvfs.rmdir', d) for f in files: f = os.path.join(source, f) xbmcvfs.delete(f) - xbmcvfs.rmdir(source) + if not xbmcvfs.rmdir(source): + raise ValueError('xbmcvfs.rmdir', source) def __delete_files_alt(source, match, del_empty): # delete files from source if match @@ -118,10 +124,12 @@ def __delete_files_alt(source, match, del_empty): for f in files: if os.path.splitext(f)[0].startswith(match): f = os.path.join(source, f) - xbmcvfs.delete(f) + if not xbmcvfs.delete(f): + raise ValueError('xbmcvfs.delete', f) # delete source directory if empty if del_empty and len(xbmcvfs.listdir(source)) == 0: - xbmcvfs.rmdir(source) + if not xbmcvfs.rmdir(source): + raise ValueError('xbmcvfs.rmdir', source) ## PRIVATE COUNT def __count_manage_directory(source): diff --git a/service.py b/service.py index 09f7f29..3723916 100644 --- a/service.py +++ b/service.py @@ -53,6 +53,20 @@ def dialog_rating(title): rating = 10 - i return rating +def ValueErrorHandler(err): + if err[0] == 'xbmcvfs.mkdirs': + log("ValueError Exception: Error creating folder: %s" % err[1]) + dialog_error(lang(30611) + ' %s' % err[1]) + if err[0] == 'xbmcvfs.rmdir': + log("ValueError Exception: Error removing folder: %s" % err[1]) + dialog_error(lang(30612) + ' %s' % err[1]) + if err[0] == 'xbmcvfs.delete': + log("ValueError Exception: Error removing file: %s" % err[1]) + dialog_error(lang(30613) + ' %s' % err[1]) + if err[0] == 'xbmcvfs.copy': + log("ValueError Exception: Error copying %s to %s" % (err[1], err[2])) + dialog_error(lang(30614) + ' %s -> %s' % (err[1], err[2])) + ## PROGRESS class Progress: def __init__(self, steps): @@ -195,6 +209,8 @@ def __move(self, progress): utilxbmc.set_movie_playcount(self.movieid, self.playcount+1) except OSError: dialog_error(lang(30610)) + except ValueError as err: + ValueErrorHandler(err) except Exception, e: dialog_error(e.message) finally: @@ -227,6 +243,8 @@ def __delete(self, progress): self.path = None except OSError: dialog_error(lang(30610)) + except ValueError as err: + ValueErrorHandler(err) except Exception, e: dialog_error(e.message) finally: @@ -444,6 +462,8 @@ def __move(self, progress): utilxbmc.set_episode_playcount(self.episodeid, self.playcount+1) except OSError: dialog_error(lang(30610)) + except ValueError as err: + ValueErrorHandler(err) except Exception, e: dialog_error(e.message) finally: @@ -470,6 +490,8 @@ def __delete(self, progress): self.path = None except OSError: dialog_error(lang(30610)) + except ValueError as err: + ValueErrorHandler(err) except Exception, e: dialog_error(e.message) finally: