mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
only do DB Connection if needed for each action
This commit is contained in:
parent
b55b4d0b96
commit
8bd44bd408
2 changed files with 71 additions and 63 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
||||||
*.pyo
|
*.pyo
|
||||||
machine_guid
|
machine_guid
|
||||||
/resources/media/Thumbs.db
|
/resources/media/Thumbs.db
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
|
|
@ -24,7 +24,7 @@ import videonodes
|
||||||
from objects import Movies, MusicVideos, TVShows, Music
|
from objects import Movies, MusicVideos, TVShows, Music
|
||||||
from utils import window, settings, language as lang, should_stop
|
from utils import window, settings, language as lang, should_stop
|
||||||
from ga_client import GoogleAnalytics
|
from ga_client import GoogleAnalytics
|
||||||
from database import DatabaseConn
|
from database import DatabaseConn, db_reset
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
@ -715,23 +715,28 @@ class LibrarySync(threading.Thread):
|
||||||
|
|
||||||
def incrementalSync(self):
|
def incrementalSync(self):
|
||||||
|
|
||||||
|
update_embydb = False
|
||||||
|
pDialog = None
|
||||||
|
|
||||||
|
# do a view update if needed
|
||||||
|
if self.refresh_views:
|
||||||
with DatabaseConn('emby') as conn_emby, DatabaseConn('video') as conn_video:
|
with DatabaseConn('emby') as conn_emby, DatabaseConn('video') as conn_video:
|
||||||
with closing(conn_emby.cursor()) as cursor_emby, closing(conn_video.cursor()) as cursor_video:
|
with closing(conn_emby.cursor()) as cursor_emby, closing(conn_video.cursor()) as cursor_video:
|
||||||
|
|
||||||
emby_db = embydb.Embydb_Functions(cursor_emby)
|
|
||||||
pDialog = None
|
|
||||||
update_embydb = False
|
|
||||||
|
|
||||||
if self.refresh_views:
|
|
||||||
# Received userconfig update
|
# Received userconfig update
|
||||||
self.refresh_views = False
|
self.refresh_views = False
|
||||||
self.maintainViews(cursor_emby, cursor_video)
|
self.maintainViews(cursor_emby, cursor_video)
|
||||||
self.forceLibraryUpdate = True
|
self.forceLibraryUpdate = True
|
||||||
update_embydb = True
|
update_embydb = True
|
||||||
|
|
||||||
incSyncIndicator = int(settings('incSyncIndicator') or 10)
|
# do a lib update if any items in list
|
||||||
totalUpdates = len(self.addedItems) + len(self.updateItems) + len(self.userdataItems) + len(self.removeItems)
|
totalUpdates = len(self.addedItems) + len(self.updateItems) + len(self.userdataItems) + len(self.removeItems)
|
||||||
|
if totalUpdates > 0:
|
||||||
|
with DatabaseConn('emby') as conn_emby, DatabaseConn('video') as conn_video:
|
||||||
|
with closing(conn_emby.cursor()) as cursor_emby, closing(conn_video.cursor()) as cursor_video:
|
||||||
|
|
||||||
|
emby_db = embydb.Embydb_Functions(cursor_emby)
|
||||||
|
|
||||||
|
incSyncIndicator = int(settings('incSyncIndicator') or 10)
|
||||||
if incSyncIndicator != -1 and totalUpdates > incSyncIndicator:
|
if incSyncIndicator != -1 and totalUpdates > incSyncIndicator:
|
||||||
# Only present dialog if we are going to process items
|
# Only present dialog if we are going to process items
|
||||||
pDialog = self.progressDialog('Incremental sync')
|
pDialog = self.progressDialog('Incremental sync')
|
||||||
|
@ -782,6 +787,7 @@ class LibrarySync(threading.Thread):
|
||||||
if kodiupdate_video:
|
if kodiupdate_video:
|
||||||
self.forceLibraryUpdate = True
|
self.forceLibraryUpdate = True
|
||||||
|
|
||||||
|
# if stuff happened then do some stuff
|
||||||
if update_embydb:
|
if update_embydb:
|
||||||
update_embydb = False
|
update_embydb = False
|
||||||
log.info("Updating emby database.")
|
log.info("Updating emby database.")
|
||||||
|
@ -904,7 +910,7 @@ class LibrarySync(threading.Thread):
|
||||||
log.warn("Database version is out of date! USER IGNORED!")
|
log.warn("Database version is out of date! USER IGNORED!")
|
||||||
dialog.ok(lang(29999), lang(33023))
|
dialog.ok(lang(29999), lang(33023))
|
||||||
else:
|
else:
|
||||||
database.db_reset()
|
db_reset()
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue