Delete cache during reset
Offer to delete cached artwork, and also drop tables in case we need to modify the structure in the future.
This commit is contained in:
parent
dfa5c7b313
commit
90c6b064c7
1 changed files with 34 additions and 3 deletions
|
@ -6,6 +6,7 @@ import cProfile
|
||||||
import inspect
|
import inspect
|
||||||
import pstats
|
import pstats
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import os
|
||||||
from datetime import datetime, time
|
from datetime import datetime, time
|
||||||
import time
|
import time
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
@ -144,7 +145,7 @@ def reset():
|
||||||
deleteNodes()
|
deleteNodes()
|
||||||
|
|
||||||
# Wipe the kodi databases
|
# Wipe the kodi databases
|
||||||
logMsg("EMBY", "Resetting the Kodi video database.")
|
logMsg("EMBY", "Resetting the Kodi video database.", 0)
|
||||||
connection = kodiSQL('video')
|
connection = kodiSQL('video')
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"')
|
cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"')
|
||||||
|
@ -170,7 +171,7 @@ def reset():
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
# Wipe the emby database
|
# Wipe the emby database
|
||||||
logMsg("EMBY", "Resetting the Emby database.")
|
logMsg("EMBY", "Resetting the Emby database.", 0)
|
||||||
connection = kodiSQL('emby')
|
connection = kodiSQL('emby')
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"')
|
cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"')
|
||||||
|
@ -179,15 +180,45 @@ def reset():
|
||||||
tablename = row[0]
|
tablename = row[0]
|
||||||
if tablename != "version":
|
if tablename != "version":
|
||||||
cursor.execute("DELETE FROM " + tablename)
|
cursor.execute("DELETE FROM " + tablename)
|
||||||
|
cursor.execute('DROP table IF EXISTS emby')
|
||||||
|
cursor.execute('DROP table IF EXISTS view')
|
||||||
connection.commit()
|
connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
# Offer to wipe cached thumbnails
|
||||||
|
resp = dialog.yesno("Warning", "Removed all cached artwork?")
|
||||||
|
if resp:
|
||||||
|
logMsg("EMBY", "Resetting all cached artwork.", 0)
|
||||||
|
# Remove all existing textures first
|
||||||
|
path = xbmc.translatePath("special://thumbnails/").decode('utf-8')
|
||||||
|
if xbmcvfs.exists(path):
|
||||||
|
allDirs, allFiles = xbmcvfs.listdir(path)
|
||||||
|
for dir in allDirs:
|
||||||
|
allDirs, allFiles = xbmcvfs.listdir(path+dir)
|
||||||
|
for file in allFiles:
|
||||||
|
if os.path.supports_unicode_filenames:
|
||||||
|
xbmcvfs.delete(os.path.join(path+dir.decode('utf-8'),file.decode('utf-8')))
|
||||||
|
else:
|
||||||
|
xbmcvfs.delete(os.path.join(path.encode('utf-8')+dir,file))
|
||||||
|
|
||||||
|
# remove all existing data from texture DB
|
||||||
|
connection = kodiSQL('texture')
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"')
|
||||||
|
rows = cursor.fetchall()
|
||||||
|
for row in rows:
|
||||||
|
tableName = row[0]
|
||||||
|
if(tableName != "version"):
|
||||||
|
cursor.execute("DELETE FROM " + tableName)
|
||||||
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
|
||||||
# reset the install run flag
|
# reset the install run flag
|
||||||
settings('SyncInstallRunDone', value="false")
|
settings('SyncInstallRunDone', value="false")
|
||||||
|
|
||||||
# Remove emby info
|
# Remove emby info
|
||||||
resp = dialog.yesno("Warning", "Reset all Emby Addon settings?")
|
resp = dialog.yesno("Warning", "Reset all Emby Addon settings?")
|
||||||
if resp == 1:
|
if resp:
|
||||||
# Delete the settings
|
# Delete the settings
|
||||||
addon = xbmcaddon.Addon()
|
addon = xbmcaddon.Addon()
|
||||||
addondir = xbmc.translatePath(addon.getAddonInfo('profile')).decode('utf-8')
|
addondir = xbmc.translatePath(addon.getAddonInfo('profile')).decode('utf-8')
|
||||||
|
|
Loading…
Reference in a new issue