Skip to content

Commit

Permalink
See #4657. Fallback to copying cache if moving cache fails due to per…
Browse files Browse the repository at this point in the history
…mission error.
  • Loading branch information
Moult committed May 11, 2024
1 parent c3fbb11 commit 00ae680
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/blenderbim/blenderbim/bim/ifc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
import bpy
import uuid
import shutil
import hashlib
import zipfile
import tempfile
Expand Down Expand Up @@ -121,7 +122,13 @@ def update_cache():
ifc_hash = hashlib.md5(ifc_key.encode("utf-8")).hexdigest()
new_cache_path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "cache", f"{ifc_hash}.h5")
IfcStore.cache = None
os.replace(IfcStore.cache_path, new_cache_path)
try:
shutil.move(IfcStore.cache_path, new_cache_path)
except PermissionError:
try:
shutil.copy2(IfcStore.cache_path, new_cache_path)
except PermissionError:
pass # Well we tried. No cache for you!
IfcStore.get_cache()

@staticmethod
Expand Down

0 comments on commit 00ae680

Please sign in to comment.