Commit 3a4bbb83 authored by echel0n's avatar echel0n

Refactored TV show class episode cache back to list but use set() to dedupe the cache

parent 2e40a978
......@@ -53,7 +53,7 @@ from sickrage.indexers.exceptions import indexer_attributenotfound
class TVShow(object):
def __init__(self, indexer_id, indexer, lang='en', location=''):
self.lock = threading.Lock()
self._episodes = set()
self._episodes = []
with sickrage.app.main_db.session() as session:
try:
......@@ -370,7 +370,7 @@ class TVShow(object):
with sickrage.app.main_db.session() as session:
query = session.query(MainDB.TVShow).filter_by(indexer_id=self.indexer_id, indexer=self.indexer).one()
for x in query.episodes:
self._episodes.add(TVEpisode(showid=self.indexer_id, indexer=self.indexer, season=x.season, episode=x.episode))
self._episodes.append(TVEpisode(showid=self.indexer_id, indexer=self.indexer, season=x.season, episode=x.episode))
return self._episodes
@property
......@@ -668,7 +668,8 @@ class TVShow(object):
if no_create:
raise EpisodeNotFoundException
tv_episode = TVEpisode(showid=self.indexer_id, indexer=self.indexer, season=season, episode=episode)
self._episodes.add(tv_episode)
self._episodes.append(tv_episode)
self._episodes = list(set(self._episodes))
return tv_episode
except orm.exc.MultipleResultsFound:
if absolute_number is not None:
......
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