diff --git a/CHANGES.md b/CHANGES.md index 1e5de442..39954b35 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -136,6 +136,7 @@ * Add tip to search settings/media search about improved matching with optional regex library * Change use value of "Update shows during hour" in General Settings straight after it is saved instead of after restart * Change add tips for what to use for Growl notifications on Windows +* Change if a newly added show is not found on indexer, remove already created empty folder [develop changelog] diff --git a/sickbeard/show_queue.py b/sickbeard/show_queue.py index dfa0f941..7a6965a9 100644 --- a/sickbeard/show_queue.py +++ b/sickbeard/show_queue.py @@ -19,6 +19,7 @@ from __future__ import with_statement import traceback +import os import sickbeard @@ -30,6 +31,7 @@ from sickbeard import name_cache from sickbeard.exceptions import ex from sickbeard.helpers import should_delete_episode from sickbeard.blackandwhitelist import BlackAndWhiteList +from sickbeard import encodingKludge as ek class ShowQueue(generic_queue.GenericQueue): @@ -175,10 +177,10 @@ class ShowQueue(generic_queue.GenericQueue): def addShow(self, indexer, indexer_id, showDir, default_status=None, quality=None, flatten_folders=None, lang='en', subtitles=None, anime=None, scene=None, paused=None, blacklist=None, whitelist=None, - wanted_begin=None, wanted_latest=None, tag=None): + wanted_begin=None, wanted_latest=None, tag=None, new_show=False): queueItemObj = QueueItemAdd(indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang, subtitles, anime, scene, paused, blacklist, whitelist, - wanted_begin, wanted_latest, tag) + wanted_begin, wanted_latest, tag, new_show=new_show) self.add_item(queueItemObj) @@ -235,7 +237,8 @@ class ShowQueueItem(generic_queue.QueueItem): class QueueItemAdd(ShowQueueItem): def __init__(self, indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang, subtitles, anime, - scene, paused, blacklist, whitelist, default_wanted_begin, default_wanted_latest, tag, scheduled_update=False): + scene, paused, blacklist, whitelist, default_wanted_begin, default_wanted_latest, tag, + scheduled_update=False, new_show=False): self.indexer = indexer self.indexer_id = indexer_id @@ -253,6 +256,7 @@ class QueueItemAdd(ShowQueueItem): self.blacklist = blacklist self.whitelist = whitelist self.tag = tag + self.new_show = new_show self.show = None @@ -482,9 +486,16 @@ class QueueItemAdd(ShowQueueItem): self.finish() def _finishEarly(self): - if self.show != None: + if self.show is not None: self.show.deleteShow() + if self.new_show: + # if we adding a new show, delete the empty folder that was already created + try: + ek.ek(os.rmdir, self.showDir) + except (StandardError, Exception): + pass + self.finish() diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index b5d4f4bc..d337c86c 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -2095,7 +2095,7 @@ class CMD_ShowAddNew(ApiCall): sickbeard.showQueueScheduler.action.addShow(int(self.indexer), int(self.indexerid), showPath, newStatus, newQuality, int(self.flatten_folders), self.lang, self.subtitles, self.anime, - self.scene) # @UndefinedVariable + self.scene, new_show=True) # @UndefinedVariable return _responds(RESULT_SUCCESS, {"name": indexerName}, indexerName + " has been queued to be added") diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 9d63ae71..172b8512 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -3655,8 +3655,10 @@ class NewHomeAddShows(Home): # use the whole path if it's given, or else append the show name to the root dir to get the full show path if fullShowPath: show_dir = ek.ek(os.path.normpath, fullShowPath) + new_show = False else: show_dir = ek.ek(os.path.join, rootDir, helpers.sanitizeFileName(show_name)) + new_show = True # blanket policy - if the dir exists you should have used 'add existing show' numbnuts if ek.ek(os.path.isdir, show_dir) and not fullShowPath: @@ -3704,7 +3706,7 @@ class NewHomeAddShows(Home): sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), newQuality, flatten_folders, indexerLang, subtitles, anime, scene, None, blacklist, whitelist, - wanted_begin, wanted_latest, tag) # @UndefinedVariable + wanted_begin, wanted_latest, tag, new_show=new_show) # @UndefinedVariable # ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir) return finishAddShow()