Commit 97c55696 authored by echel0n's avatar echel0n

Refactored `delete_episode` method to remove episode object from related show episode cache.

parent c0460175
......@@ -570,9 +570,9 @@ class Core(object):
try:
self.log.info('Loading show {} and building caches'.format(show.name))
show = TVShow(show.indexer_id, show.indexer)
self.shows.update({(show.indexer_id, show.indexer): show})
self.name_cache.build(show)
self.quicksearch_cache.add_show(show.indexer_id)
self.shows.update({(show.indexer_id, show.indexer): show})
except Exception as e:
self.log.debug('There was an error loading show: {}'.format(show.name))
......
......@@ -664,6 +664,12 @@ class TVEpisode(object):
sickrage.app.log.warning('Unable to delete episode file %s: %s / %s' % (self.location, repr(e), str(e)))
# delete myself from show episode cache
try:
ep_index = self.show.episodes.index(self)
sickrage.app.log.debug("Deleting %s S%02dE%02d from the shows episode cache" % (self.show.name, self.season or 0, self.episode or 0))
del self.show.episodes[ep_index]
except ValueError:
pass
# delete myself from the database
sickrage.app.log.debug("Deleting %s S%02dE%02d from the DB" % (self.show.name, self.season or 0, self.episode or 0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment