Validate braindance state recovery
This commit is contained in:
1 parent
9dbd6b7873
commit
1de1130da4
1 file changed
+5
-2
@@ -241,8 +241,11 @@ def _load_state():
|
|||||||
try:
|
try:
|
||||||
with open(path, encoding='utf-8') as f:
|
with open(path, encoding='utf-8') as f:
|
||||||
candidate = json.load(f)
|
candidate = json.load(f)
|
||||||
if not isinstance(candidate, dict):
|
required_maps = ('USERS', 'RECORDS', 'COLLECTIONS', 'COMMENTS', 'FOLLOWS', 'TAG_INDEX')
|
||||||
raise ValueError('state root must be an object')
|
if (not isinstance(candidate, dict)
|
||||||
|
or any(not isinstance(candidate.get(name), dict) for name in required_maps)
|
||||||
|
or not isinstance(candidate.get('FEED'), list)):
|
||||||
|
raise ValueError('invalid state schema')
|
||||||
data = candidate
|
data = candidate
|
||||||
loaded_from = path
|
loaded_from = path
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in new issue
Block a user