TO BE CHECKED: better method to delete obsolete fileIds
This commit is contained in:
parent
dfcfa0edab
commit
d7541b7f74
2 changed files with 13 additions and 11 deletions
|
@ -178,11 +178,13 @@ class KodiVideoDB(common.KodiDBBase):
|
||||||
'plugin://plugin.video.plexkodiconnect'
|
'plugin://plugin.video.plexkodiconnect'
|
||||||
These entries should be deleted as they're created falsely by Kodi.
|
These entries should be deleted as they're created falsely by Kodi.
|
||||||
"""
|
"""
|
||||||
return (x[0] for x in self.cursor.execute('''
|
return (x[0] for x in self.cursor.execute("""
|
||||||
SELECT idFile FROM files
|
SELECT files.idFile
|
||||||
WHERE dateAdded IS NULL
|
FROM files
|
||||||
AND strFilename LIKE \'plugin://plugin.video.plexkodiconnect%\'
|
LEFT JOIN path ON path.idPath = files.idPath
|
||||||
'''))
|
WHERE files.dateAdded IS NULL
|
||||||
|
AND path.strPath LIKE \'%plex.direct%\'
|
||||||
|
"""))
|
||||||
|
|
||||||
def show_id_from_path(self, path):
|
def show_id_from_path(self, path):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -517,13 +517,13 @@ 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)
|
app.APP.monitor.waitForAbort(1)
|
||||||
try:
|
try:
|
||||||
with kodi_db.KodiVideoDB() as kodidb_1:
|
with kodi_db.KodiVideoDB() as kodidb:
|
||||||
with kodi_db.KodiVideoDB(lock=False) as kodidb_2:
|
file_ids = list(kodidb.obsolete_file_ids())
|
||||||
for file_id in kodidb_1.obsolete_file_ids():
|
LOG.debug('Obsolete kodi file_ids: %s', file_ids)
|
||||||
LOG.debug('Removing obsolete Kodi file_id %s', file_id)
|
for file_id in file_ids:
|
||||||
kodidb_2.remove_file(file_id, remove_orphans=False)
|
kodidb.remove_file(file_id)
|
||||||
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