From 000a8c47bf7daeacf075510182566bbdfbb4bcf0 Mon Sep 17 00:00:00 2001 From: aronwk-aaron Date: Mon, 24 Oct 2022 20:57:04 -0500 Subject: [PATCH] add sdo support for bbb models --- app/properties.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/properties.py b/app/properties.py index 13e27b2..b101d40 100644 --- a/app/properties.py +++ b/app/properties.py @@ -411,10 +411,20 @@ def download_model(id): def ugc(content): ugc_data = UGC.query.filter(UGC.id == content.ugc_id).first() - uncompressed_lxfml = zlib.decompress(ugc_data.lxfml) + uncompressed_lxfml = decompress(ugc_data.lxfml) response = make_response(uncompressed_lxfml) return response, ugc_data.filename +def decompress(data): + assert data[:5] == b"sd0\x01\xff" + pos = 5 + out = b"" + while pos < len(data): + length = int.from_bytes(data[pos:pos+4], "little") + pos += 4 + out += zlib.decompress(data[pos:pos+length]) + pos += length + return out def prebuilt(content, file_format, lod): # translate LOT to component id