mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Adjust database discovery
Compare loaded vs discovered to avoid loading old databases by accident.
This commit is contained in:
parent
c0e979c8a0
commit
ff9120c847
2 changed files with 20 additions and 13 deletions
|
@ -109,10 +109,10 @@ class Database(object):
|
|||
modified['time'] = modified_int
|
||||
modified['file'] = file.decode('utf-8')
|
||||
|
||||
LOG.info("Loading discovered database: %s", modified)
|
||||
LOG.info("Discovered database: %s", modified)
|
||||
self.discovered = True
|
||||
|
||||
return xbmc.translatePath("special://database/%s" % modified['file'])
|
||||
return xbmc.translatePath("special://database/%s" % modified['file']).decode('utf-8')
|
||||
|
||||
def _sql(self, file):
|
||||
|
||||
|
@ -122,9 +122,13 @@ class Database(object):
|
|||
'''
|
||||
databases = obj.Objects().objects
|
||||
|
||||
try:
|
||||
return self._get_database(databases[file]) if file in databases else file
|
||||
if file not in ('video', 'music', 'texture') or databases.get('database_set%s' % file):
|
||||
return self._get_database(databases[file], True)
|
||||
|
||||
discovered = self._discover_database(file) if not databases.get('database_set%s' % file) else None
|
||||
|
||||
try:
|
||||
loaded = self._get_database(databases[file]) if file in databases else file
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
|
||||
|
@ -132,19 +136,20 @@ class Database(object):
|
|||
alt_file = "%s-%s" % (file, i)
|
||||
|
||||
try:
|
||||
if file not in ('video', 'music', 'texture'):
|
||||
return self._get_database(databases[file], True)
|
||||
|
||||
databases[file] = self._get_database(databases[alt_file])
|
||||
|
||||
return databases[file]
|
||||
loaded = self._get_database(databases[alt_file])
|
||||
except KeyError: # No other db options
|
||||
databases[file] = self._discover_database(file)
|
||||
|
||||
return databases[file]
|
||||
loaded = None
|
||||
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
databases[file] = discovered if discovered and discovered != loaded else loaded
|
||||
databases['database_set%s' % file] = True
|
||||
LOG.info("Database locked in: %s", databases[file])
|
||||
|
||||
return databases[file]
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
|
||||
''' Close the connection and cursor.
|
||||
|
|
|
@ -128,6 +128,8 @@ class Library(threading.Thread):
|
|||
|
||||
LOG.info("Newly discovered database: %s", kodidb.path)
|
||||
settings('DiscoveredDatabase', kodidb.path)
|
||||
self.monitor.settings['enable_db_discovery'] = True
|
||||
settings('AskDiscoverDatabase.bool', True)
|
||||
|
||||
return False
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue