Fix for transactionals and None Types in sql lists

This commit is contained in:
echel0n 2014-05-30 04:42:31 -07:00
parent db6cf0b22b
commit 997896a540
22 changed files with 57 additions and 40 deletions

View file

@ -81,7 +81,7 @@ class DailySearcher():
sql_l.append(ep.get_sql())
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)

View file

@ -30,6 +30,7 @@ from sickbeard import encodingKludge as ek
from sickbeard import logger
from sickbeard.exceptions import ex
from sickbeard.common import cpu_presets
from itertools import ifilter
db_lock = threading.Lock()
@ -113,6 +114,8 @@ class DBConnection:
def mass_action(self, querylist, logTransaction=False):
with db_lock:
# remove None types
querylist = [i for i in querylist if i!=None]
if querylist == None:
return

View file

@ -186,7 +186,7 @@ def update_network_dict():
L = list(va for va in old_d)
ql.append(["DELETE FROM network_timezones WHERE network_name IN (" + ','.join(['?'] * len(L)) + ")", L])
# change all network timezone infos at once (much faster)
if len(ql) > 0:
if ql:
myDB.mass_action(ql)
load_network_dict()

View file

@ -961,7 +961,7 @@ class PostProcessor(object):
else:
self._log(u"Couldn't find release in snatch history", logger.WARNING)
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)
@ -1038,7 +1038,7 @@ class PostProcessor(object):
ep_obj.createMetaFiles()
sql_l.append(ep_obj.get_sql())
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)

View file

@ -341,8 +341,9 @@ class BTNCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
else:
raise AuthException(

View file

@ -233,8 +233,9 @@ class HDBitsCache(tvcache.TVCache):
if ci is not None:
ql.append(ci)
myDB = self._getDB()
myDB.mass_action(ql)
if ql:
myDB = self._getDB()
myDB.mass_action(ql)
else:
raise exceptions.AuthException(

View file

@ -367,8 +367,9 @@ class HDTorrentsCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
def _parseItem(self, item):

View file

@ -308,8 +308,9 @@ class IPTorrentsCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
def _parseItem(self, item):

View file

@ -445,8 +445,9 @@ class KATCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
def _parseItem(self, item):

View file

@ -341,8 +341,9 @@ class NewznabCache(tvcache.TVCache):
if ci is not None:
ql.append(ci)
myDB = self._getDB()
myDB.mass_action(ql)
if ql:
myDB = self._getDB()
myDB.mass_action(ql)
else:
raise AuthException(

View file

@ -357,8 +357,9 @@ class NextGenCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
def _parseItem(self, item):

View file

@ -337,8 +337,9 @@ class PublicHDCache(tvcache.TVCache):
if ci is not None:
ql.append(ci)
myDB = self._getDB()
myDB.mass_action(ql)
if ql:
myDB = self._getDB()
myDB.mass_action(ql)
def _parseItem(self, item):

View file

@ -352,8 +352,9 @@ class SCCCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
def _parseItem(self, item):

View file

@ -292,8 +292,9 @@ class SpeedCDCache(tvcache.TVCache):
if ci is not None:
ql.append(ci)
myDB = self._getDB()
myDB.mass_action(ql)
if ql:
myDB = self._getDB()
myDB.mass_action(ql)
def _parseItem(self, item):

View file

@ -427,8 +427,9 @@ class ThePirateBayCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
def _parseItem(self, item):

View file

@ -315,8 +315,9 @@ class TorrentDayCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
def _parseItem(self, item):

View file

@ -311,8 +311,9 @@ class TorrentLeechCache(tvcache.TVCache):
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
def _parseItem(self, item):

View file

@ -174,7 +174,7 @@ def snatchEpisode(result, endStatus=SNATCHED):
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj._format_pattern('%SN - %Sx%0E - %EN - %QN'))
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)

View file

@ -421,7 +421,7 @@ class TVShow(object):
sql_l.append(curEpisode.get_sql())
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)
@ -542,7 +542,7 @@ class TVShow(object):
scannedEps[season][episode] = True
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)
@ -712,7 +712,7 @@ class TVShow(object):
with curEp.lock:
sql_l.append(curEp.get_sql())
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)
@ -1039,7 +1039,7 @@ class TVShow(object):
if sickbeard.AIRDATE_EPISODES:
self.airdateModifyStamp(curEp)
if len(sql_l):
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)
@ -2312,6 +2312,6 @@ class TVEpisode(object):
for relEp in self.relatedEps:
sql_l.append(relEp.get_sql())
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)

View file

@ -128,8 +128,9 @@ class TVCache():
if ci is not None:
cl.append(ci)
myDB = self._getDB()
myDB.mass_action(cl)
if cl:
myDB = self._getDB()
myDB.mass_action(cl)
else:
raise AuthException(

View file

@ -1011,7 +1011,7 @@ class CMD_EpisodeSetStatus(ApiCall):
start_backlog = True
ep_results.append(_epResult(RESULT_SUCCESS, epObj))
if len(sql_l):
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)

View file

@ -3528,7 +3528,7 @@ class Home:
# mass add to database
sql_l.append(epObj.get_sql())
if len(sql_l) > 0:
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)