From fb364a2275a733aaebcaabfb5d39e6faf5449662 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 24 Nov 2018 09:56:30 +0100 Subject: [PATCH] Safety net for cleaning Kodi file table --- resources/lib/kodimonitor.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 75496fa6..5e24f390 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -524,9 +524,13 @@ def _clean_file_table(): """ LOG.debug('Start cleaning Kodi files table') app.APP.monitor.waitForAbort(2) - with kodi_db.KodiVideoDB() as kodidb_1: - with kodi_db.KodiVideoDB() as kodidb_2: - for file_id in kodidb_1.obsolete_file_ids(): - LOG.debug('Removing obsolete Kodi file_id %s', file_id) - kodidb_2.remove_file(file_id, remove_orphans=False) - LOG.debug('Done cleaning up Kodi file table') + try: + with kodi_db.KodiVideoDB() as kodidb_1: + with kodi_db.KodiVideoDB() as kodidb_2: + for file_id in kodidb_1.obsolete_file_ids(): + LOG.debug('Removing obsolete Kodi file_id %s', file_id) + kodidb_2.remove_file(file_id, remove_orphans=False) + except utils.OperationalError: + LOG.debug('Database was locked, unable to clean file table') + else: + LOG.debug('Done cleaning up Kodi file table')