Force show sync if user manually initiated
This commit is contained in:
parent
743d8dbb2f
commit
a2b145e4ec
1 changed files with 19 additions and 12 deletions
|
@ -70,6 +70,8 @@ class LibrarySync(Thread):
|
||||||
self.enableBackgroundSync = settings(
|
self.enableBackgroundSync = settings(
|
||||||
'enableBackgroundSync') == "true"
|
'enableBackgroundSync') == "true"
|
||||||
|
|
||||||
|
# Show sync dialog even if user deactivated?
|
||||||
|
self.force_dialog = True
|
||||||
# Init for replacing paths
|
# Init for replacing paths
|
||||||
window('remapSMB', value=settings('remapSMB'))
|
window('remapSMB', value=settings('remapSMB'))
|
||||||
window('replaceSMB', value=settings('replaceSMB'))
|
window('replaceSMB', value=settings('replaceSMB'))
|
||||||
|
@ -82,22 +84,19 @@ class LibrarySync(Thread):
|
||||||
window('kodiplextimeoffset', value=str(self.timeoffset))
|
window('kodiplextimeoffset', value=str(self.timeoffset))
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
|
|
||||||
def showKodiNote(self, message, forced=False, icon="plex"):
|
def showKodiNote(self, message, icon="plex"):
|
||||||
"""
|
"""
|
||||||
Shows a Kodi popup, if user selected to do so. Pass message in unicode
|
Shows a Kodi popup, if user selected to do so. Pass message in unicode
|
||||||
or string
|
or string
|
||||||
|
|
||||||
icon: "plex": shows Plex icon
|
icon: "plex": shows Plex icon
|
||||||
"error": shows Kodi error icon
|
"error": shows Kodi error icon
|
||||||
|
|
||||||
forced: always show popup, even if user setting to off
|
|
||||||
"""
|
"""
|
||||||
if self.xbmcplayer.isPlaying():
|
if self.xbmcplayer.isPlaying():
|
||||||
# Don't show any dialog if media is playing
|
# Don't show any dialog if media is playing
|
||||||
return
|
return
|
||||||
if state.SYNC_DIALOG is not True:
|
if state.SYNC_DIALOG is not True and self.force_dialog is not True:
|
||||||
if not forced:
|
return
|
||||||
return
|
|
||||||
if icon == "plex":
|
if icon == "plex":
|
||||||
dialog('notification',
|
dialog('notification',
|
||||||
heading='{plex}',
|
heading='{plex}',
|
||||||
|
@ -735,7 +734,8 @@ class LibrarySync(Thread):
|
||||||
thread.start()
|
thread.start()
|
||||||
threads.append(thread)
|
threads.append(thread)
|
||||||
# Start one thread to show sync progress ONLY for new PMS items
|
# Start one thread to show sync progress ONLY for new PMS items
|
||||||
if self.new_items_only is True and state.SYNC_DIALOG is True:
|
if self.new_items_only is True and (state.SYNC_DIALOG is True or
|
||||||
|
self.force_dialog is True):
|
||||||
thread = sync_info.Threaded_Show_Sync_Info(itemNumber, itemType)
|
thread = sync_info.Threaded_Show_Sync_Info(itemNumber, itemType)
|
||||||
thread.setDaemon(True)
|
thread.setDaemon(True)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
@ -1445,6 +1445,8 @@ class LibrarySync(Thread):
|
||||||
xbmc.sleep(1000)
|
xbmc.sleep(1000)
|
||||||
|
|
||||||
if (window('plex_dbCheck') != "true" and installSyncDone):
|
if (window('plex_dbCheck') != "true" and installSyncDone):
|
||||||
|
# Install sync was already done, don't force-show dialogs
|
||||||
|
self.force_dialog = False
|
||||||
# Verify the validity of the database
|
# Verify the validity of the database
|
||||||
currentVersion = settings('dbCreatedWithVersion')
|
currentVersion = settings('dbCreatedWithVersion')
|
||||||
minVersion = window('plex_minDBVersion')
|
minVersion = window('plex_minDBVersion')
|
||||||
|
@ -1514,11 +1516,14 @@ class LibrarySync(Thread):
|
||||||
settings('SyncInstallRunDone', value="true")
|
settings('SyncInstallRunDone', value="true")
|
||||||
settings("dbCreatedWithVersion", v.ADDON_VERSION)
|
settings("dbCreatedWithVersion", v.ADDON_VERSION)
|
||||||
installSyncDone = True
|
installSyncDone = True
|
||||||
|
self.force_dialog = False
|
||||||
else:
|
else:
|
||||||
log.error("Initial start-up full sync unsuccessful")
|
log.error("Initial start-up full sync unsuccessful")
|
||||||
|
|
||||||
# Currently no db scan, so we can start a new scan
|
# Currently no db scan, so we can start a new scan
|
||||||
elif state.DB_SCAN is False:
|
elif state.DB_SCAN is False:
|
||||||
|
# Force-show dialogs since they are user-initiated
|
||||||
|
self.force_dialog = True
|
||||||
# Full scan was requested from somewhere else, e.g. userclient
|
# Full scan was requested from somewhere else, e.g. userclient
|
||||||
if window('plex_runLibScan') in ("full", "repair"):
|
if window('plex_runLibScan') in ("full", "repair"):
|
||||||
log.info('Full library scan requested, starting')
|
log.info('Full library scan requested, starting')
|
||||||
|
@ -1532,7 +1537,7 @@ class LibrarySync(Thread):
|
||||||
window('plex_dbScan', clear=True)
|
window('plex_dbScan', clear=True)
|
||||||
state.DB_SCAN = False
|
state.DB_SCAN = False
|
||||||
# Full library sync finished
|
# Full library sync finished
|
||||||
self.showKodiNote(lang(39407), forced=True)
|
self.showKodiNote(lang(39407))
|
||||||
# Reset views was requested from somewhere else
|
# Reset views was requested from somewhere else
|
||||||
elif window('plex_runLibScan') == "views":
|
elif window('plex_runLibScan') == "views":
|
||||||
log.info('Refresh playlist and nodes requested, starting')
|
log.info('Refresh playlist and nodes requested, starting')
|
||||||
|
@ -1549,13 +1554,12 @@ class LibrarySync(Thread):
|
||||||
# Ran successfully
|
# Ran successfully
|
||||||
log.info("Refresh playlists/nodes completed")
|
log.info("Refresh playlists/nodes completed")
|
||||||
# "Plex playlists/nodes refreshed"
|
# "Plex playlists/nodes refreshed"
|
||||||
self.showKodiNote(lang(39405), forced=True)
|
self.showKodiNote(lang(39405))
|
||||||
else:
|
else:
|
||||||
# Failed
|
# Failed
|
||||||
log.error("Refresh playlists/nodes failed")
|
log.error("Refresh playlists/nodes failed")
|
||||||
# "Plex playlists/nodes refresh failed"
|
# "Plex playlists/nodes refresh failed"
|
||||||
self.showKodiNote(lang(39406),
|
self.showKodiNote(lang(39406),
|
||||||
forced=True,
|
|
||||||
icon="error")
|
icon="error")
|
||||||
window('plex_dbScan', clear=True)
|
window('plex_dbScan', clear=True)
|
||||||
state.DB_SCAN = False
|
state.DB_SCAN = False
|
||||||
|
@ -1579,6 +1583,8 @@ class LibrarySync(Thread):
|
||||||
state.DB_SCAN = False
|
state.DB_SCAN = False
|
||||||
else:
|
else:
|
||||||
now = getUnixTimestamp()
|
now = getUnixTimestamp()
|
||||||
|
# Standard syncs - don't force-show dialogs
|
||||||
|
self.force_dialog = False
|
||||||
if (now - lastSync > fullSyncInterval and
|
if (now - lastSync > fullSyncInterval and
|
||||||
not self.xbmcplayer.isPlaying()):
|
not self.xbmcplayer.isPlaying()):
|
||||||
lastSync = now
|
lastSync = now
|
||||||
|
@ -1587,13 +1593,14 @@ class LibrarySync(Thread):
|
||||||
window('plex_dbScan', value="true")
|
window('plex_dbScan', value="true")
|
||||||
if fullSync() is False and not thread_stopped():
|
if fullSync() is False and not thread_stopped():
|
||||||
log.error('Could not finish scheduled full sync')
|
log.error('Could not finish scheduled full sync')
|
||||||
|
self.force_dialog = True
|
||||||
self.showKodiNote(lang(39410),
|
self.showKodiNote(lang(39410),
|
||||||
forced=True,
|
|
||||||
icon='error')
|
icon='error')
|
||||||
|
self.force_dialog = False
|
||||||
window('plex_dbScan', clear=True)
|
window('plex_dbScan', clear=True)
|
||||||
state.DB_SCAN = False
|
state.DB_SCAN = False
|
||||||
# Full library sync finished
|
# Full library sync finished
|
||||||
self.showKodiNote(lang(39407), forced=False)
|
self.showKodiNote(lang(39407))
|
||||||
elif now - lastTimeSync > oneDay:
|
elif now - lastTimeSync > oneDay:
|
||||||
lastTimeSync = now
|
lastTimeSync = now
|
||||||
log.info('Starting daily time sync')
|
log.info('Starting daily time sync')
|
||||||
|
|
Loading…
Reference in a new issue