mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 21:53: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())
|
sql_l.append(ep.get_sql())
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ from sickbeard import encodingKludge as ek
|
||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
from sickbeard.common import cpu_presets
|
from sickbeard.common import cpu_presets
|
||||||
|
from itertools import ifilter
|
||||||
|
|
||||||
db_lock = threading.Lock()
|
db_lock = threading.Lock()
|
||||||
|
|
||||||
|
@ -113,6 +114,8 @@ class DBConnection:
|
||||||
def mass_action(self, querylist, logTransaction=False):
|
def mass_action(self, querylist, logTransaction=False):
|
||||||
|
|
||||||
with db_lock:
|
with db_lock:
|
||||||
|
# remove None types
|
||||||
|
querylist = [i for i in querylist if i!=None]
|
||||||
|
|
||||||
if querylist == None:
|
if querylist == None:
|
||||||
return
|
return
|
||||||
|
|
|
@ -186,7 +186,7 @@ def update_network_dict():
|
||||||
L = list(va for va in old_d)
|
L = list(va for va in old_d)
|
||||||
ql.append(["DELETE FROM network_timezones WHERE network_name IN (" + ','.join(['?'] * len(L)) + ")", L])
|
ql.append(["DELETE FROM network_timezones WHERE network_name IN (" + ','.join(['?'] * len(L)) + ")", L])
|
||||||
# change all network timezone infos at once (much faster)
|
# change all network timezone infos at once (much faster)
|
||||||
if len(ql) > 0:
|
if ql:
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
load_network_dict()
|
load_network_dict()
|
||||||
|
|
||||||
|
|
|
@ -961,7 +961,7 @@ class PostProcessor(object):
|
||||||
else:
|
else:
|
||||||
self._log(u"Couldn't find release in snatch history", logger.WARNING)
|
self._log(u"Couldn't find release in snatch history", logger.WARNING)
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
@ -1038,7 +1038,7 @@ class PostProcessor(object):
|
||||||
ep_obj.createMetaFiles()
|
ep_obj.createMetaFiles()
|
||||||
sql_l.append(ep_obj.get_sql())
|
sql_l.append(ep_obj.get_sql())
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
|
|
@ -341,6 +341,7 @@ class BTNCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,7 @@ class HDBitsCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
ql.append(ci)
|
ql.append(ci)
|
||||||
|
|
||||||
|
if ql:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
|
|
||||||
|
|
|
@ -367,6 +367,7 @@ class HDTorrentsCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -308,6 +308,7 @@ class IPTorrentsCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -445,6 +445,7 @@ class KATCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -341,6 +341,7 @@ class NewznabCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
ql.append(ci)
|
ql.append(ci)
|
||||||
|
|
||||||
|
if ql:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
|
|
||||||
|
|
|
@ -357,6 +357,7 @@ class NextGenCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,7 @@ class PublicHDCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
ql.append(ci)
|
ql.append(ci)
|
||||||
|
|
||||||
|
if ql:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
|
|
||||||
|
|
|
@ -352,6 +352,7 @@ class SCCCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -292,6 +292,7 @@ class SpeedCDCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
ql.append(ci)
|
ql.append(ci)
|
||||||
|
|
||||||
|
if ql:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(ql)
|
myDB.mass_action(ql)
|
||||||
|
|
||||||
|
|
|
@ -427,6 +427,7 @@ class ThePirateBayCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -315,6 +315,7 @@ class TorrentDayCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -311,6 +311,7 @@ class TorrentLeechCache(tvcache.TVCache):
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ def snatchEpisode(result, endStatus=SNATCHED):
|
||||||
if curEpObj.status not in Quality.DOWNLOADED:
|
if curEpObj.status not in Quality.DOWNLOADED:
|
||||||
notifiers.notify_snatch(curEpObj._format_pattern('%SN - %Sx%0E - %EN - %QN'))
|
notifiers.notify_snatch(curEpObj._format_pattern('%SN - %Sx%0E - %EN - %QN'))
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ class TVShow(object):
|
||||||
|
|
||||||
sql_l.append(curEpisode.get_sql())
|
sql_l.append(curEpisode.get_sql())
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ class TVShow(object):
|
||||||
|
|
||||||
scannedEps[season][episode] = True
|
scannedEps[season][episode] = True
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ class TVShow(object):
|
||||||
with curEp.lock:
|
with curEp.lock:
|
||||||
sql_l.append(curEp.get_sql())
|
sql_l.append(curEp.get_sql())
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
@ -1039,7 +1039,7 @@ class TVShow(object):
|
||||||
if sickbeard.AIRDATE_EPISODES:
|
if sickbeard.AIRDATE_EPISODES:
|
||||||
self.airdateModifyStamp(curEp)
|
self.airdateModifyStamp(curEp)
|
||||||
|
|
||||||
if len(sql_l):
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
@ -2312,6 +2312,6 @@ class TVEpisode(object):
|
||||||
for relEp in self.relatedEps:
|
for relEp in self.relatedEps:
|
||||||
sql_l.append(relEp.get_sql())
|
sql_l.append(relEp.get_sql())
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
|
@ -128,6 +128,7 @@ class TVCache():
|
||||||
if ci is not None:
|
if ci is not None:
|
||||||
cl.append(ci)
|
cl.append(ci)
|
||||||
|
|
||||||
|
if cl:
|
||||||
myDB = self._getDB()
|
myDB = self._getDB()
|
||||||
myDB.mass_action(cl)
|
myDB.mass_action(cl)
|
||||||
|
|
||||||
|
|
|
@ -1011,7 +1011,7 @@ class CMD_EpisodeSetStatus(ApiCall):
|
||||||
start_backlog = True
|
start_backlog = True
|
||||||
ep_results.append(_epResult(RESULT_SUCCESS, epObj))
|
ep_results.append(_epResult(RESULT_SUCCESS, epObj))
|
||||||
|
|
||||||
if len(sql_l):
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
|
|
@ -3528,7 +3528,7 @@ class Home:
|
||||||
# mass add to database
|
# mass add to database
|
||||||
sql_l.append(epObj.get_sql())
|
sql_l.append(epObj.get_sql())
|
||||||
|
|
||||||
if len(sql_l) > 0:
|
if sql_l:
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.mass_action(sql_l)
|
myDB.mass_action(sql_l)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue