mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-13 21:56:11 +00:00
fix db stuff (#164)
* Reload objects upon initial setup * Fix database discovery ignore db-journal
This commit is contained in:
parent
2a4e42fba0
commit
2bbd5bf3a9
3 changed files with 29 additions and 27 deletions
|
@ -99,7 +99,8 @@ class Database(object):
|
||||||
modified = {'file': None, 'time': 0}
|
modified = {'file': None, 'time': 0}
|
||||||
|
|
||||||
for file in reversed(files):
|
for file in reversed(files):
|
||||||
if file.startswith(database) and not file.endswith('-wal') and not file.endswith('-shm'):
|
if (file.startswith(database) and not file.endswith('-wal') and
|
||||||
|
not file.endswith('-shm') and not file.endswith('db-journal')):
|
||||||
|
|
||||||
st = xbmcvfs.Stat(databases + file.decode('utf-8'))
|
st = xbmcvfs.Stat(databases + file.decode('utf-8'))
|
||||||
modified_int = st.st_mtime()
|
modified_int = st.st_mtime()
|
||||||
|
|
|
@ -200,7 +200,7 @@ class Service(xbmc.Monitor):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
get_objects(zipfile, label + '.zip')
|
get_objects(zipfile, label + '.zip')
|
||||||
reload(objects) # to apply latest changes
|
self.reload_objects()
|
||||||
|
|
||||||
dialog("notification", heading="{emby}", message=_(33156), icon="{emby}")
|
dialog("notification", heading="{emby}", message=_(33156), icon="{emby}")
|
||||||
LOG.info("--[ new objects/%s ]", objects.version)
|
LOG.info("--[ new objects/%s ]", objects.version)
|
||||||
|
@ -477,6 +477,30 @@ class Service(xbmc.Monitor):
|
||||||
if not self.settings['kodi_companion']:
|
if not self.settings['kodi_companion']:
|
||||||
dialog("ok", heading="{emby}", line1=_(33138))
|
dialog("ok", heading="{emby}", line1=_(33138))
|
||||||
|
|
||||||
|
def reload_objects(self):
|
||||||
|
|
||||||
|
''' Reload objects which depends on the patch module.
|
||||||
|
This allows to see the changes in code without restarting the python interpreter.
|
||||||
|
'''
|
||||||
|
import full_sync
|
||||||
|
|
||||||
|
reload_modules = ['objects.movies', 'objects.musicvideos', 'objects.tvshows',
|
||||||
|
'objects.music', 'objects.obj', 'objects.actions', 'objects.kodi.kodi',
|
||||||
|
'objects.kodi.movies', 'objects.kodi.musicvideos', 'objects.kodi.tvshows',
|
||||||
|
'objects.kodi.music', 'objects.kodi.artwork', 'objects.kodi.queries',
|
||||||
|
'objects.kodi.queries_music', 'objects.kodi.queries_texture']
|
||||||
|
|
||||||
|
for mod in reload_modules:
|
||||||
|
del sys.modules[mod]
|
||||||
|
|
||||||
|
reload(objects.kodi)
|
||||||
|
reload(objects)
|
||||||
|
reload(library)
|
||||||
|
reload(full_sync)
|
||||||
|
reload(monitor)
|
||||||
|
|
||||||
|
LOG.warn("---[ objects reloaded ]")
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
|
||||||
LOG.warn("---<[ EXITING ]")
|
LOG.warn("---<[ EXITING ]")
|
||||||
|
|
27
service.py
27
service.py
|
@ -65,6 +65,8 @@ class ServiceManager(threading.Thread):
|
||||||
|
|
||||||
if not 'ExitService' in error and service is not None:
|
if not 'ExitService' in error and service is not None:
|
||||||
service.shutdown()
|
service.shutdown()
|
||||||
|
elif 'RestartService' in error:
|
||||||
|
service.reload_objects()
|
||||||
|
|
||||||
self.exception = error
|
self.exception = error
|
||||||
|
|
||||||
|
@ -82,31 +84,6 @@ if __name__ == "__main__":
|
||||||
session.join() # Block until the thread exits.
|
session.join() # Block until the thread exits.
|
||||||
|
|
||||||
if 'RestartService' in session.exception:
|
if 'RestartService' in session.exception:
|
||||||
|
|
||||||
''' Reload objects which depends on the patch module.
|
|
||||||
'''
|
|
||||||
LOG.warn("--[ RESTART ]")
|
|
||||||
|
|
||||||
import objects
|
|
||||||
import library
|
|
||||||
import full_sync
|
|
||||||
import monitor
|
|
||||||
|
|
||||||
reload_modules = ['objects.movies', 'objects.musicvideos', 'objects.tvshows',
|
|
||||||
'objects.music', 'objects.obj', 'objects.actions', 'objects.kodi.kodi',
|
|
||||||
'objects.kodi.movies', 'objects.kodi.musicvideos', 'objects.kodi.tvshows',
|
|
||||||
'objects.kodi.music', 'objects.kodi.artwork', 'objects.kodi.queries',
|
|
||||||
'objects.kodi.queries_music', 'objects.kodi.queries_texture']
|
|
||||||
|
|
||||||
for mod in reload_modules:
|
|
||||||
del sys.modules[mod]
|
|
||||||
|
|
||||||
reload(objects.kodi)
|
|
||||||
reload(objects)
|
|
||||||
reload(library)
|
|
||||||
reload(full_sync)
|
|
||||||
reload(monitor)
|
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|
Loading…
Reference in a new issue