mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +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['time'] = modified_int
|
||||||
modified['file'] = file.decode('utf-8')
|
modified['file'] = file.decode('utf-8')
|
||||||
|
|
||||||
LOG.info("Loading discovered database: %s", modified)
|
LOG.info("Discovered database: %s", modified)
|
||||||
self.discovered = True
|
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):
|
def _sql(self, file):
|
||||||
|
|
||||||
|
@ -122,9 +122,13 @@ class Database(object):
|
||||||
'''
|
'''
|
||||||
databases = obj.Objects().objects
|
databases = obj.Objects().objects
|
||||||
|
|
||||||
try:
|
if file not in ('video', 'music', 'texture') or databases.get('database_set%s' % file):
|
||||||
return self._get_database(databases[file]) if file in databases else 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:
|
except Exception as error:
|
||||||
LOG.error(error)
|
LOG.error(error)
|
||||||
|
|
||||||
|
@ -132,19 +136,20 @@ class Database(object):
|
||||||
alt_file = "%s-%s" % (file, i)
|
alt_file = "%s-%s" % (file, i)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if file not in ('video', 'music', 'texture'):
|
loaded = self._get_database(databases[alt_file])
|
||||||
return self._get_database(databases[file], True)
|
|
||||||
|
|
||||||
databases[file] = self._get_database(databases[alt_file])
|
|
||||||
|
|
||||||
return databases[file]
|
|
||||||
except KeyError: # No other db options
|
except KeyError: # No other db options
|
||||||
databases[file] = self._discover_database(file)
|
loaded = None
|
||||||
|
|
||||||
return databases[file]
|
break
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
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):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
|
||||||
''' Close the connection and cursor.
|
''' Close the connection and cursor.
|
||||||
|
|
|
@ -128,6 +128,8 @@ class Library(threading.Thread):
|
||||||
|
|
||||||
LOG.info("Newly discovered database: %s", kodidb.path)
|
LOG.info("Newly discovered database: %s", kodidb.path)
|
||||||
settings('DiscoveredDatabase', kodidb.path)
|
settings('DiscoveredDatabase', kodidb.path)
|
||||||
|
self.monitor.settings['enable_db_discovery'] = True
|
||||||
|
settings('AskDiscoverDatabase.bool', True)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue