Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 00ae680

Browse files
committed
See IfcOpenShell#4657. Fallback to copying cache if moving cache fails due to permission error.
1 parent c3fbb11 commit 00ae680

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • src/blenderbim/blenderbim/bim

src/blenderbim/blenderbim/bim/ifc.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import os
2020
import bpy
2121
import uuid
22+
import shutil
2223
import hashlib
2324
import zipfile
2425
import tempfile
@@ -121,7 +122,13 @@ def update_cache():
121122
ifc_hash = hashlib.md5(ifc_key.encode("utf-8")).hexdigest()
122123
new_cache_path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "cache", f"{ifc_hash}.h5")
123124
IfcStore.cache = None
124-
os.replace(IfcStore.cache_path, new_cache_path)
125+
try:
126+
shutil.move(IfcStore.cache_path, new_cache_path)
127+
except PermissionError:
128+
try:
129+
shutil.copy2(IfcStore.cache_path, new_cache_path)
130+
except PermissionError:
131+
pass # Well we tried. No cache for you!
125132
IfcStore.get_cache()
126133

127134
@staticmethod

0 commit comments

Comments
 (0)