mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-03 01:43:37 +00:00
Fix for transactionals and None Types in sql lists
This commit is contained in:
parent
db6cf0b22b
commit
997896a540
22 changed files with 57 additions and 40 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue