Do not save unnecessary data for PIO Home

This commit is contained in:
Ivan Kravets
2019-07-16 14:15:48 +03:00
parent 425c1fb0a8
commit 71c4201487
2 changed files with 13 additions and 1 deletions

View File

@ -157,6 +157,9 @@ class State(object):
self.modified = True
return self._storage.update(*args, **kwargs)
def clear(self):
return self._storage.clear()
def __getitem__(self, key):
return self._storage[key]

View File

@ -25,6 +25,11 @@ class AppRPC(object):
APPSTATE_PATH = join(get_project_core_dir(), "homestate.json")
IGNORE_STORAGE_KEYS = [
"cid", "coreVersion", "coreSystype", "coreCaller", "coreSettings",
"homeDir", "projectsDir"
]
@staticmethod
def load_state():
with app.State(AppRPC.APPSTATE_PATH, lock=True) as state:
@ -66,6 +71,10 @@ class AppRPC(object):
@staticmethod
def save_state(state):
with app.State(AppRPC.APPSTATE_PATH, lock=True) as s:
# s.clear()
s.clear()
s.update(state)
storage = s.get("storage", {})
for k in AppRPC.IGNORE_STORAGE_KEYS:
if k in storage:
del storage[k]
return True