Merge pull request #1034 from croneter/fix-filetable
Optimize clean-up of file table in the Kodi video database after stopping playback
This commit is contained in:
commit
38636b6943
1 changed files with 8 additions and 6 deletions
|
@ -463,13 +463,15 @@ def _clean_file_table():
|
||||||
This function tries for at most 5 seconds to clean the file table.
|
This function tries for at most 5 seconds to clean the file table.
|
||||||
"""
|
"""
|
||||||
LOG.debug('Start cleaning Kodi files table')
|
LOG.debug('Start cleaning Kodi files table')
|
||||||
app.APP.monitor.waitForAbort(2)
|
if app.APP.monitor.waitForAbort(2):
|
||||||
|
# PKC should exit
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
with kodi_db.KodiVideoDB() as kodidb_1:
|
with kodi_db.KodiVideoDB() as kodidb:
|
||||||
with kodi_db.KodiVideoDB(lock=False) as kodidb_2:
|
obsolete_file_ids = list(kodidb.obsolete_file_ids())
|
||||||
for file_id in kodidb_1.obsolete_file_ids():
|
for file_id in obsolete_file_ids:
|
||||||
LOG.debug('Removing obsolete Kodi file_id %s', file_id)
|
LOG.debug('Removing obsolete Kodi file_id %s', file_id)
|
||||||
kodidb_2.remove_file(file_id, remove_orphans=False)
|
kodidb.remove_file(file_id, remove_orphans=False)
|
||||||
except utils.OperationalError:
|
except utils.OperationalError:
|
||||||
LOG.debug('Database was locked, unable to clean file table')
|
LOG.debug('Database was locked, unable to clean file table')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue