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

@ -1049,7 +1049,7 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper):
def draw(self, context):
pass
def execute(self, context):
from replication.repository import Repository
@ -1058,7 +1058,31 @@ class SessionLoadSaveOperator(bpy.types.Operator, ImportHelper):
# init the factory with supported types
bpy_protocol = bl_types.get_data_translation_protocol()
repo = Repository(bpy_protocol)
repo.loads(self.filepath)
try:
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
ignored_datablocks = []