Fix OperationalError: database is locked
This commit is contained in:
parent
d2922d61f5
commit
9d6f729b21
1 changed files with 19 additions and 8 deletions
|
@ -17,6 +17,13 @@ SYNC_FANART = utils.settings('FanartTV') == 'true'
|
||||||
PREFER_KODI_COLLECTION_ART = utils.settings('PreferKodiCollectionArt') == 'false'
|
PREFER_KODI_COLLECTION_ART = utils.settings('PreferKodiCollectionArt') == 'false'
|
||||||
|
|
||||||
|
|
||||||
|
def suspends():
|
||||||
|
return (app.SYNC.suspend_library_thread or
|
||||||
|
app.SYNC.stop_sync or
|
||||||
|
app.SYNC.db_scan or
|
||||||
|
app.SYNC.suspend_sync)
|
||||||
|
|
||||||
|
|
||||||
class FanartThread(backgroundthread.KillableThread):
|
class FanartThread(backgroundthread.KillableThread):
|
||||||
"""
|
"""
|
||||||
This will potentially take hours!
|
This will potentially take hours!
|
||||||
|
@ -27,10 +34,7 @@ class FanartThread(backgroundthread.KillableThread):
|
||||||
super(FanartThread, self).__init__()
|
super(FanartThread, self).__init__()
|
||||||
|
|
||||||
def isSuspended(self):
|
def isSuspended(self):
|
||||||
return (app.SYNC.suspend_library_thread or
|
return suspends()
|
||||||
app.SYNC.stop_sync or
|
|
||||||
app.SYNC.db_scan or
|
|
||||||
app.SYNC.suspend_sync)
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
|
@ -140,8 +144,15 @@ def process_fanart(plex_id, plex_type, refresh=False):
|
||||||
setid,
|
setid,
|
||||||
v.KODI_TYPE_SET)
|
v.KODI_TYPE_SET)
|
||||||
done = True
|
done = True
|
||||||
|
except utils.OperationalError:
|
||||||
|
# We were not fast enough when a sync started
|
||||||
|
pass
|
||||||
finally:
|
finally:
|
||||||
if done is True:
|
if done is True and not suspends():
|
||||||
|
try:
|
||||||
with PlexDB() as plexdb:
|
with PlexDB() as plexdb:
|
||||||
plexdb.set_fanart_synced(plex_id,
|
plexdb.set_fanart_synced(plex_id,
|
||||||
plex_type)
|
plex_type)
|
||||||
|
except utils.OperationalError:
|
||||||
|
# We were not fast enough when a sync started
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in a new issue