From e5d4269c10f82ce1ffae60de0cb24407289885fd Mon Sep 17 00:00:00 2001 From: JackDandy Date: Sun, 29 Mar 2015 12:20:29 +0100 Subject: [PATCH] Change only add valid items to save to DB. --- CHANGES.md | 1 + sickbeard/tv.py | 30 ++++++++++++++++++++---------- sickbeard/webapi.py | 6 ++++-- sickbeard/webserve.py | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 891a7aba..0f8116be 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -92,6 +92,7 @@ * Add "File logging level" to General Config/Advanced Settings * Fix saving of Sort By/Next Episode in Layout Poster on Show List page * Change improve backlog search +* Change only add valid items to save to DB [develop changelog] * Fix traceback error when using the menu item Manage/Update Kodi diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 5f338682..aa629f81 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -453,9 +453,11 @@ class TVShow(object): logger.log(str(self.indexerid) + ": Could not refresh subtitles", logger.ERROR) logger.log(traceback.format_exc(), logger.DEBUG) - sql_l.append(curEpisode.get_sql()) + result = curEpisode.get_sql() + if None is not result: + sql_l.append(result) - if len(sql_l) > 0: + if 0 < len(sql_l): myDB = db.DBConnection() myDB.mass_action(sql_l) @@ -573,11 +575,13 @@ class TVShow(object): self.indexer).name + " for episode " + str(season) + "x" + str(episode), logger.DEBUG) ep.loadFromIndexer(season, episode, tvapi=t) - sql_l.append(ep.get_sql()) + result = ep.get_sql() + if None is not result: + sql_l.append(result) scannedEps[season][episode] = True - if len(sql_l) > 0: + if 0 < len(sql_l): myDB = db.DBConnection() myDB.mass_action(sql_l) @@ -731,9 +735,11 @@ class TVShow(object): curEp.status = Quality.compositeStatus(newStatus, newQuality) with curEp.lock: - sql_l.append(curEp.get_sql()) + result = curEp.get_sql() + if None is not result: + sql_l.append(result) - if len(sql_l) > 0: + if 0 < len(sql_l): myDB = db.DBConnection() myDB.mass_action(sql_l) @@ -1127,13 +1133,15 @@ class TVShow(object): curEp.hastbn = False curEp.release_name = '' - sql_l.append(curEp.get_sql()) + result = curEp.get_sql() + if None is not result: + sql_l.append(result) else: # the file exists, set its modify file stamp if sickbeard.AIRDATE_EPISODES: curEp.airdateModifyStamp() - if len(sql_l) > 0: + if 0 < len(sql_l): myDB = db.DBConnection() myDB.mass_action(sql_l) @@ -2511,9 +2519,11 @@ class TVEpisode(object): sql_l = [] with self.lock: for relEp in [self] + self.relatedEps: - sql_l.append(relEp.get_sql()) + result = relEp.get_sql() + if None is not result: + sql_l.append(result) - if len(sql_l) > 0: + if 0 < len(sql_l): myDB = db.DBConnection() myDB.mass_action(sql_l) diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index 7fa3e3ef..9fd8afcc 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -999,13 +999,15 @@ class CMD_EpisodeSetStatus(ApiCall): continue epObj.status = self.status - sql_l.append(epObj.get_sql()) + result = epObj.get_sql() + if None is not result: + sql_l.append(result) if self.status == WANTED: start_backlog = True ep_results.append(_epResult(RESULT_SUCCESS, epObj)) - if len(sql_l) > 0: + if 0 < len(sql_l): myDB = db.DBConnection() myDB.mass_action(sql_l) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index be916001..ee319cc2 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -1561,7 +1561,7 @@ class Home(MainHandler): if None is not result: sql_l.append(result) - if len(sql_l) > 0: + if 0 < len(sql_l): myDB = db.DBConnection() myDB.mass_action(sql_l)