Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updater fails to remove staging directory because zip file is used by process #80

Closed
agajdosi opened this issue May 5, 2022 · 2 comments

Comments

@agajdosi
Copy link

agajdosi commented May 5, 2022

From our error logs in BlenderKit addon:

blenderkit addon: Error: Failed to remove existing staging directory, consider manually removing C:\Users\agajdosi\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\blenderkit\../../addons_updates/blenderkit_updater\update_staging
Traceback (most recent call last):
  File "C:\Users\agajdosi\AppData\Roaming\Blender Foundation\Blender\3.1\scripts\addons\blenderkit\addon_updater.py", line 1109, in deep_merge_directory
  File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\shutil.py", line 739, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\shutil.py", line 617, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\lib\shutil.py", line 615, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\agajdosi\\AppData\\Roaming\\Blender Foundation\\Blender\\3.1\\scripts\\addons\\blenderkit\\../../addons_updates/blenderkit_updater\\update_staging\\source.zip'
blenderkit addon: Wrote out updater JSON settings with content:
blenderkit addon: {'last_check': '2022-05-04 13:18:11.589117', 'backup_date': 'May-4-2022', 'update_ready': True, 'ignore': False, 'just_restored': False, 'just_updated': True, 'version_text': {'link': 'https://api.github.com/repos/BlenderKit/blenderkit/zipball/v3.1.3', 'version': (3, 1, 3)}}
Restart blender to reload addon and complete update
blenderkit addon: blenderkit updater: Running post update callback
Updater returned successful

It seems to me, that zip file is not being closed which is the reason for the error. I have tried to call the function zipfile.ZipFile(self._source_zip, "r") which opens the file via with - as statement in the def unpack_staged_zip(self, clean=False): , which solved the issue for us:

with zipfile.ZipFile(self._source_zip, "r") as zfile:

Would be glad to create a PR :)

@TheDuckCow
Copy link
Collaborator

Hi @agajdosi so sorry for the crazy long delay here, I somehow missed the notification. Would love to have this pr! If you don't get to it, I certainly will as indeed - using a with context manager is definitely the right way to do this.

TheDuckCow added a commit that referenced this issue Aug 11, 2022
Addresses #80, all tests pass locally
@agajdosi
Copy link
Author

Seems fixed in 1.1.1. Thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants