nvda
69f64e46 - Fix add-on store crash when download directory cleanup fails (#19828)

Commit
3 days ago
Fix add-on store crash when download directory cleanup fails (#19828) Fixes #19202 Summary of the issue: When the add-on store download directory (addonStore/_dl) is locked by an external process, shutil.rmtree raises an unhandled PermissionError during AddonFileDownloader.__init__. AddonFileDownloader is instantiated as a class-level attribute of AddonStoreVM. The exception propagates through module initialization and causes a CRITICAL - core failure that crashes NVDA. A similar unprotected shutil.rmtree call exists in AddonFileDownloader.cancelAll. This would crash NVDA when closing the add-on store dialog if the directory is locked. Description of user facing changes: NVDA no longer crashes when the add-on store download directory cannot be cleaned up due to file permission errors. If cleanup fails, NVDA logs a warning and continues normally. The existing __init__ cleanup will retry removal on the next startup. Description of developer facing changes: None. Description of development approach: Both shutil.rmtree calls in AddonFileDownloader (__init__ and cancelAll) are wrapped in try-except OSError blocks with log.error(exc_info=True) (was log.debugWarning but maintainer asked to change this to log.error). OSError is used because shutil.rmtree can raise various OSError subclasses depending on the failure mode. This matches the pattern used in installer.py (e.g. tryRemoveFile and _deleteFileGroupOrFail). In __init__, the mkdir(parents=True, exist_ok=True) call remains outside the try-except block. This ensures the download directory always exists, even if cleanup of the previous contents failed. In cancelAll, a failed cleanup is not critical. _downloader is a class-level attribute that is only re-created on the next NVDA restart. At that point __init__ will retry the cleanup. This PR was developed with AI assistance (Claude Code) with human review and manual testing.
Parents
Loading