|
|
@ -247,8 +247,18 @@ class ChangeDetectionStore:
|
|
|
|
|
|
|
|
|
|
|
|
def sync_to_json(self):
|
|
|
|
def sync_to_json(self):
|
|
|
|
print("Saving..")
|
|
|
|
print("Saving..")
|
|
|
|
|
|
|
|
data ={}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
data = deepcopy(self.__data)
|
|
|
|
|
|
|
|
except RuntimeError:
|
|
|
|
|
|
|
|
time.sleep(0.5)
|
|
|
|
|
|
|
|
print ("! Data changed when writing to JSON, trying again..")
|
|
|
|
|
|
|
|
self.sync_to_json()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
else:
|
|
|
|
with open(self.json_store_path, 'w') as json_file:
|
|
|
|
with open(self.json_store_path, 'w') as json_file:
|
|
|
|
json.dump(self.__data, json_file, indent=4)
|
|
|
|
json.dump(data, json_file, indent=4)
|
|
|
|
logging.info("Re-saved index")
|
|
|
|
logging.info("Re-saved index")
|
|
|
|
|
|
|
|
|
|
|
|
self.needs_write = False
|
|
|
|
self.needs_write = False
|
|
|
@ -263,6 +273,6 @@ class ChangeDetectionStore:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
if self.needs_write:
|
|
|
|
if self.needs_write:
|
|
|
|
self.sync_to_json()
|
|
|
|
self.sync_to_json()
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# body of the constructor
|
|
|
|
time.sleep(3)
|
|
|
|
|
|
|
|
|
|
|
|