bernhard-42 / vscode-ocp-cad-viewer

A viewer for OCP based Code-CAD (CadQuery, build123d) integrated into VS Code
Apache License 2.0
78 stars 9 forks source link

Permission error on Windows #65

Closed Jojain closed 3 months ago

Jojain commented 4 months ago

It happens that on windows we get permission errors due to the code in ocp_tessellate/ocp_utils

def deserialize(buffer):
    if buffer is None:
        return None

    shape = TopoDS_Shape()
    try:
        bio = io.BytesIO(buffer)
        BinTools.Read_s(shape, bio)
    except Exception:
        with tempfile.NamedTemporaryFile() as tf:
            with open(tf.name, "wb") as fd:
                fd.write(buffer)
            BinTools.Read_s(shape, tf.name)
    return shape

The issue comes from the fact that tf is an already opened file and we try to open it twice. The python docs says that it's platform dependent and on windows opening it twice doesnt work.

bernhard-42 commented 3 months ago

fixed in 2.2.2