From e7c543aa42e86d1993749d57ba7bfafecd6f5715 Mon Sep 17 00:00:00 2001 From: JackDandy Date: Thu, 5 Aug 2021 11:45:23 +0100 Subject: [PATCH] Change media process move process method for *nix systems that don't support native move. A copy/unlink method is used on systems that fail a native Python move; source file is no longer removed if the destination file fails. Fix do not display empty show name results returned from TVDb. --- CHANGES.md | 8 +++++++- lib/sg_helpers.py | 8 ++++++-- lib/tvdb_api/tvdb_api.py | 14 +++++++------- sickbeard/postProcessor.py | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6b98acf..ef630c8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,10 @@ -### 0.24.14 (2021-07-31 08:50:00 UTC) +### 0.24.15 (2021-08-05 11:45:00 UTC) + +* Change media process move process method for *nix systems that don't support native move +* Fix do not display empty show name results returned from TVDb + + +### 0.24.14 (2021-07-31 08:50:00 UTC) * Change add compatibility for Transmission 3.00 client with label support * Change ensure cookies are split only into 2 parts at the lhs of multiple occurrences of '=' diff --git a/lib/sg_helpers.py b/lib/sg_helpers.py index be784e6..dac1493 100644 --- a/lib/sg_helpers.py +++ b/lib/sg_helpers.py @@ -1171,13 +1171,17 @@ def copy_file(src_file, dest_file): pass -def move_file(src_file, dest_file): +def move_file(src_file, dest_file, raise_exceptions=False): try: ek.ek(shutil.move, src_file, dest_file) fix_set_group_id(dest_file) except OSError: copy_file(src_file, dest_file) - ek.ek(os.unlink, src_file) + if ek.ek(os.path.exists, dest_file): + fix_set_group_id(dest_file) + ek.ek(os.unlink, src_file) + elif raise_exceptions: + raise OSError('Destination file could not be created: %s' % dest_file) def remove_file_perm(filepath, log_err=True): diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index 27b60da..d8a73bd 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -456,13 +456,13 @@ class Tvdb(TVInfoBase): v = '' else: v = clean_data(v) - else: - if 'seriesname' == k: - if isinstance(data.get('aliases'), list) and 0 < len(data.get('aliases')): - v = data['aliases'].pop(0) - # this is a invalid show, it has no Name - if None is v: - return None + + if not v and 'seriesname' == k: + if isinstance(data.get('aliases'), list) and 0 < len(data.get('aliases')): + v = data['aliases'].pop(0) + # this is a invalid show, it has no Name + if not v: + return None if k in map_show: k = map_show[k] diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 29033b3..51358c2 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -353,7 +353,7 @@ class PostProcessor(object): def _int_move(cur_file_path, new_file_path, success_tmpl=u' %s to %s'): try: - helpers.move_file(cur_file_path, new_file_path) + helpers.move_file(cur_file_path, new_file_path, raise_exceptions=True) helpers.chmod_as_parent(new_file_path) self._log(u'Moved file from' + (success_tmpl % (cur_file_path, new_file_path)), logger.DEBUG) except (IOError, OSError) as e: