From c5b5a7af0cb282b7a7ff7ab551f17c1a4466682e Mon Sep 17 00:00:00 2001 From: JackDandy Date: Wed, 13 Jun 2018 02:50:06 +0100 Subject: [PATCH] Fix issue when deleting files and "Send to trash for actions" is enabled. --- CHANGES.md | 1 + sickbeard/helpers.py | 1 + sickbeard/image_cache.py | 1 - sickbeard/postProcessor.py | 13 +------------ sickbeard/processTV.py | 14 ++------------ sickbeard/tv.py | 5 ----- sickbeard/webserve.py | 1 - 7 files changed, 5 insertions(+), 31 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 88a20c88..1df4a4f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ [develop changelog] +* Fix issue when deleting files and "Send to trash for actions" is enabled diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index a80461d8..098c0146 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -42,6 +42,7 @@ import adba import requests import requests.exceptions from cfscrape import CloudflareScraper +from lib.send2trash import send2trash import sickbeard import subliminal diff --git a/sickbeard/image_cache.py b/sickbeard/image_cache.py index 4a7a19ec..b8a2b26e 100644 --- a/sickbeard/image_cache.py +++ b/sickbeard/image_cache.py @@ -33,7 +33,6 @@ from sickbeard.metadata.generic import GenericMetadata from lib.hachoir.parser import createParser from lib.hachoir.metadata import extractMetadata -from lib.send2trash import send2trash try: import zlib except: diff --git a/sickbeard/postProcessor.py b/sickbeard/postProcessor.py index 6fe4ed72..584c12ed 100644 --- a/sickbeard/postProcessor.py +++ b/sickbeard/postProcessor.py @@ -43,11 +43,6 @@ from sickbeard.name_parser.parser import NameParser, InvalidNameException, Inval from lib import adba -try: - from lib.send2trash import send2trash -except ImportError: - pass - class PostProcessor(object): """ @@ -235,13 +230,7 @@ class PostProcessor(object): except: self._log(u'Cannot change permissions to writeable to delete file: %s' % cur_file, logger.WARNING) - try: - if self.use_trash: - ek.ek(send2trash, cur_file) - else: - ek.ek(os.remove, cur_file) - except OSError as e: - self._log(u'Unable to delete file %s: %s' % (cur_file, str(e.strerror)), logger.DEBUG) + helpers.remove_file(cur_file, log_level=logger.DEBUG) if True is not ek.ek(os.path.isfile, cur_file): self._log(u'Deleted file ' + cur_file, logger.DEBUG) diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py index 4208e1c3..b9d0eb4b 100644 --- a/sickbeard/processTV.py +++ b/sickbeard/processTV.py @@ -48,11 +48,6 @@ try: except ImportError: from lib import simplejson as json -try: - from lib.send2trash import send2trash -except ImportError: - pass - # noinspection PyArgumentList class ProcessTVShow(object): @@ -150,13 +145,8 @@ class ProcessTVShow(object): ek.ek(os.chmod, cur_file_path, stat.S_IWRITE) except OSError as e: self._log_helper(u'Cannot change permissions of %s: %s' % (cur_file_path, str(e.strerror))) - try: - if use_trash: - ek.ek(send2trash, cur_file_path) - else: - ek.ek(os.remove, cur_file_path) - except OSError as e: - self._log_helper(u'Unable to delete file %s: %s' % (cur_file, str(e.strerror))) + + helpers.remove_file(cur_file_path) if ek.ek(os.path.isfile, cur_file_path): result = False diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 0573ef47..a68818da 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -38,11 +38,6 @@ import fnmatch from imdb._exceptions import IMDbError -try: - from lib.send2trash import send2trash -except ImportError: - pass - from lib.imdb import imdb from sickbeard import db diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index be8684f2..f49f1771 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -77,7 +77,6 @@ from trakt_helpers import build_config, trakt_collection_remove_account from sickbeard.bs4_parser import BS4Parser from lib.fuzzywuzzy import fuzz -from lib.send2trash import send2trash from lib.tmdb_api import TMDB from lib.tvdb_api.tvdb_exceptions import tvdb_exception