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:
|
||||
with open(path, encoding='utf-8') as f:
|
||||
candidate = json.load(f)
|
||||
if not isinstance(candidate, dict):
|
||||
raise ValueError('state root must be an object')
|
||||
required_maps = ('USERS', 'RECORDS', 'COLLECTIONS', 'COMMENTS', 'FOLLOWS', 'TAG_INDEX')
|
||||
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
|
||||
loaded_from = path
|
||||
break
|
||||
|
||||
Reference in new issue
Block a user