feat: groundd work on legacy snapshots loading

This commit is contained in:
Swann 2021-12-10 16:57:03 +01:00
parent fe998214be
commit 3fbe769928

View File

@ -1058,7 +1058,31 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper):
# init the factory with supported types # init the factory with supported types
bpy_protocol = bl_types.get_data_translation_protocol() bpy_protocol = bl_types.get_data_translation_protocol()
repo = Repository(bpy_protocol) repo = Repository(bpy_protocol)
try:
repo.loads(self.filepath) repo.loads(self.filepath)
except TypeError:
# Load legacy snapshots
db = pickle.load(gzip.open(self.filepath, "rb"))
nodes = db.get("nodes")
logging.info(f"Loading legacy {len(nodes)} node")
repo.object_store.clear()
for node, node_data in nodes:
instance = Node(
uuid=node,
data=node_data.get('data'),
owner=node_data.get('owner'),
dependencies=node_data.get('dependencies'),
state=FETCHED)
# Patch data for compatibility
type_id = node_data.get('str_type')[2:]
if type_id == "File":
type_id = "WindowsPath"
instance.data['type_id'] = type_id
repo.do_commit(instance)
instance.state = FETCHED
# Persitstent collection # Persitstent collection
ignored_datablocks = [] ignored_datablocks = []