Fix OperationalError and PKC not starting up
This commit is contained in:
parent
531b2dedb3
commit
b87ba4c753
1 changed files with 20 additions and 21 deletions
|
@ -105,33 +105,32 @@ def wipe_dbs(music=True):
|
||||||
"""
|
"""
|
||||||
Completely resets the Kodi databases 'video', 'texture' and 'music' (if
|
Completely resets the Kodi databases 'video', 'texture' and 'music' (if
|
||||||
music sync is enabled)
|
music sync is enabled)
|
||||||
|
|
||||||
|
DO NOT use context menu as we need to connect without WAL mode - if Kodi
|
||||||
|
is still accessing the DB
|
||||||
"""
|
"""
|
||||||
|
from sqlite3 import connect
|
||||||
LOG.warn('Wiping Kodi databases!')
|
LOG.warn('Wiping Kodi databases!')
|
||||||
kinds = [KodiVideoDB, KodiTextureDB]
|
kinds = [v.DB_VIDEO_PATH, v.DB_TEXTURE_PATH]
|
||||||
if music:
|
if music:
|
||||||
kinds.append(KodiMusicDB)
|
kinds.append(v.DB_TEXTURE_PATH)
|
||||||
for db in kinds:
|
for path in kinds:
|
||||||
with db() as kodidb:
|
conn = connect(path, timeout=5.0)
|
||||||
kodidb.cursor.execute("SELECT name FROM sqlite_master WHERE type = 'table'")
|
cursor = conn.cursor()
|
||||||
tables = kodidb.cursor.fetchall()
|
cursor.execute("SELECT name FROM sqlite_master WHERE type = 'table'")
|
||||||
|
tables = cursor.fetchall()
|
||||||
tables = [i[0] for i in tables]
|
tables = [i[0] for i in tables]
|
||||||
if 'version' in tables:
|
if 'version' in tables:
|
||||||
tables.remove('version')
|
tables.remove('version')
|
||||||
if 'versiontagscan' in tables:
|
if 'versiontagscan' in tables:
|
||||||
tables.remove('versiontagscan')
|
tables.remove('versiontagscan')
|
||||||
for table in tables:
|
for table in tables:
|
||||||
kodidb.cursor.execute('DELETE FROM %s' % table)
|
cursor.execute('DELETE FROM %s' % table)
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
setup_kodi_default_entries()
|
setup_kodi_default_entries()
|
||||||
# Delete SQLITE wal files
|
# Delete SQLITE wal files
|
||||||
import xbmc
|
import xbmc
|
||||||
db_dir = xbmc.translatePath('special://database').decode('utf-8')
|
|
||||||
for root, _, files in path_ops.walk(db_dir):
|
|
||||||
for file in files:
|
|
||||||
if path_ops.path.splitext(file)[1].lower() in ('.db-shm', '.db-wal'):
|
|
||||||
try:
|
|
||||||
path_ops.remove(path_ops.path.join(root, file))
|
|
||||||
except OSError:
|
|
||||||
LOG.info('Could not delete temp DB file %s', file)
|
|
||||||
# Make sure Kodi knows we wiped the databases
|
# Make sure Kodi knows we wiped the databases
|
||||||
xbmc.executebuiltin('UpdateLibrary(video)')
|
xbmc.executebuiltin('UpdateLibrary(video)')
|
||||||
if utils.settings('enableMusic') == 'true':
|
if utils.settings('enableMusic') == 'true':
|
||||||
|
|
Loading…
Reference in a new issue