Bonsai: retry the .blend save in save_project when the file is briefly locked (#9506) - #9507
Open
theoryshaw wants to merge 1 commit into
Open
theoryshaw wants to merge 1 commit into
theoryshaw wants to merge 1 commit into
Conversation
…y locked Saving the IFC also saves the synced .blend. Blender writes "<file>.blend@" and renames it over the .blend; on Windows that rename fails while Dropbox, OneDrive or antivirus has the file open, raising "Cannot change old file (file saved with @)" and aborting the operator with a traceback even though the IFC was already written. Retry the .blend save a few times with a short delay, and if it still fails, report a warning instead of raising. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9506.
Problem
bim.save_projectalso saves the synced.blend. Blender writes<file>.blend@and then renames it over the.blend. On Windows that rename fails while Dropbox, OneDrive or antivirus briefly holds the file open. The operator then aborts withRuntimeError: Error: Cannot change old file (file saved with @), even though the IFC has already been written.Fix
save_blend_file_with_retries()inproject/operator.pytrieswm.save_mainfileup to 5 times, 200 ms apart, and prints each failed attempt.save_projectreports a warning (IFC saved,.blendnot saved, plus the error) instead of raising.Verification
Headless Blender 5.2 on Windows. The
.blendwas locked from another thread withopen(path, "rb"), which doesn't share delete, and the helper's source was run straight from this file:save_version = 0Cannot change old file (file saved with @), no raiseVersion backup failed (file saved with @), no raiseA raw
wm.save_mainfileunder the same lock raises the reported error, so the repro matches the bug. The fullsave_projectoperator was not run with the add-on enabled; only the helper was exercised.🤖 Generated with Claude Code