mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Always use highest version database available
This commit is contained in:
parent
a78ab1377c
commit
54a425fde4
1 changed files with 13 additions and 13 deletions
|
@ -7,6 +7,7 @@ import json
|
||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
from kodi_six import xbmc, xbmcvfs
|
from kodi_six import xbmc, xbmcvfs
|
||||||
from six import text_type
|
from six import text_type
|
||||||
|
@ -112,25 +113,24 @@ class Database(object):
|
||||||
}
|
}
|
||||||
database = types[database]
|
database = types[database]
|
||||||
dirs, files = xbmcvfs.listdir(databases)
|
dirs, files = xbmcvfs.listdir(databases)
|
||||||
modified = {'db_file': None, 'time': 0}
|
target = {'db_file': '', 'version': 0}
|
||||||
|
|
||||||
for db_file in reversed(files):
|
for db_file in reversed(files):
|
||||||
|
if (db_file.startswith(database) and not db_file.endswith('-wal')
|
||||||
|
and not db_file.endswith('-shm')
|
||||||
|
and not db_file.endswith('db-journal')):
|
||||||
|
|
||||||
if (db_file.startswith(database) and not db_file.endswith('-wal') and not db_file.endswith('-shm') and not db_file.endswith('db-journal')):
|
version_string = re.search('{}(.*).db'.format(database), db_file)
|
||||||
|
version = int(version_string.group(1))
|
||||||
|
|
||||||
st = xbmcvfs.Stat(databases + db_file)
|
if version > target['version']:
|
||||||
modified_int = st.st_mtime()
|
target['db_file'] = db_file
|
||||||
LOG.debug("Database detected: %s time: %s", db_file, modified_int)
|
target['version'] = version
|
||||||
|
|
||||||
if modified_int > modified['time']:
|
LOG.debug("Discovered database: %s", target)
|
||||||
|
self.discovered_file = target['db_file']
|
||||||
|
|
||||||
modified['time'] = modified_int
|
return xbmc.translatePath("special://database/%s" % target['db_file'])
|
||||||
modified['db_file'] = db_file
|
|
||||||
|
|
||||||
LOG.debug("Discovered database: %s", modified)
|
|
||||||
self.discovered_file = modified['db_file']
|
|
||||||
|
|
||||||
return xbmc.translatePath("special://database/%s" % modified['db_file'])
|
|
||||||
|
|
||||||
def _sql(self, db_file):
|
def _sql(self, db_file):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue