Fix OperationalError: Database is locked

This commit is contained in:
croneter 2018-11-26 19:40:43 +01:00
parent 0e335dd35e
commit ccdb76709e
2 changed files with 12 additions and 6 deletions

View file

@ -5,7 +5,7 @@ from logging import getLogger
from .get_metadata import GetMetadataTask, reset_collections
from .process_metadata import InitNewSection, UpdateLastSync, ProcessMetadata, \
DeleteItem
DeleteItem, UpdateUserdata
from . import common, sections
from .. import utils, timing, backgroundthread, variables as v, app
from .. import plex_functions as PF, itemtypes
@ -78,11 +78,10 @@ class FullSync(common.libsync_mixin):
Updates the playstate (resume point, number of views, userrating, last
played date, etc.) for all elements in the (xml-)iterator
"""
with self.context(self.current_sync) as c:
for xml_item in iterator:
if self.isCanceled():
return False
c.update_userdata(xml_item, self.plex_type)
for xml_item in iterator:
if self.isCanceled():
return False
self.queue.put(UpdateUserdata(xml_item))
@utils.log_time
def process_kind(self):

View file

@ -29,6 +29,11 @@ class InitNewSection(object):
self.plex_type = plex_type
class UpdateUserdata(object):
def __init__(self, xml_item):
self.xml_item = xml_item
class UpdateLastSync(object):
def __init__(self, plex_id):
self.plex_id = plex_id
@ -130,6 +135,8 @@ class ProcessMetadata(common.libsync_mixin, backgroundthread.KillableThread):
context.plexdb.update_last_sync(item.plex_id,
section.plex_type,
self.last_sync)
elif isinstance(item, UpdateUserdata):
context.update_userdata(item.xml_item, section.plex_type)
elif isinstance(item, InitNewSection) or item is None:
section = item
self.queue.task_done()