From ddaf662f1cd770f5389bb73c0ef315082ad448d6 Mon Sep 17 00:00:00 2001 From: faush01 Date: Mon, 12 Nov 2018 15:59:47 +1100 Subject: [PATCH] dont save the new cache data until the display process finishes --- addon.xml | 2 +- resources/lib/datamanager.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addon.xml b/addon.xml index 46cb920..4913ba4 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/lib/datamanager.py b/resources/lib/datamanager.py index edd4016..404678f 100644 --- a/resources/lib/datamanager.py +++ b/resources/lib/datamanager.py @@ -131,9 +131,12 @@ class CacheManagerThread(threading.Thread): xbmc.sleep(100) loops = loops + 1 wait_refresh = home_window.getProperty("wait_refresh") + log.debug("CacheManagerThread : Saving New Data loops({0})", loops) + with open(self.cache_file, 'wb') as handle: cPickle.dump(self.fresh_data, handle, protocol=cPickle.HIGHEST_PROTOCOL) + home_window.clearProperty("wait_refresh") else: @@ -162,8 +165,6 @@ class CacheManagerThread(threading.Thread): # if they dont match then save the data and trigger a content reload if cached_hash != loaded_hash: log.debug("CacheManagerThread : Saving new cache data and reloading container") - with open(self.cache_file, 'wb') as handle: - cPickle.dump(loaded_items, handle, protocol=cPickle.HIGHEST_PROTOCOL) # we need to refresh but will wait until the main function has finished loops = 0 @@ -174,6 +175,9 @@ class CacheManagerThread(threading.Thread): loops = loops + 1 wait_refresh = home_window.getProperty("wait_refresh") + with open(self.cache_file, 'wb') as handle: + cPickle.dump(loaded_items, handle, protocol=cPickle.HIGHEST_PROTOCOL) + home_window.clearProperty("wait_refresh") log.debug("CacheManagerThread : Sending container refresh ({0})", loops) xbmc.executebuiltin("Container.Refresh")