From 7b916973798fe612ada23e7fa5e05a71340e2061 Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Tue, 6 Jun 2023 15:29:08 +1000 Subject: [PATCH] Add-on store: only make directories if should write to disk (#14968) Fix up of #14955 Raised in #14912 (comment) Summary of the issue: Caching directories are still created when NVDA should not write to disk Description of user facing changes Caching directories are no longer created when NVDA should not write to disk Description of development approach Caching directories are no longer created when NVDA should not write to disk --- source/_addonStore/dataManager.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/_addonStore/dataManager.py b/source/_addonStore/dataManager.py index edea266e98a..0c8cf281448 100644 --- a/source/_addonStore/dataManager.py +++ b/source/_addonStore/dataManager.py @@ -76,10 +76,12 @@ def __init__(self): self._cacheCompatibleFile = os.path.join(cacheDirLocation, _DataManager._cacheCompatibleFilename) self._addonDownloadCacheDir = os.path.join(cacheDirLocation, "_dl") self._installedAddonDataCacheDir = os.path.join(cacheDirLocation, "addons") - # ensure caching dirs exist - pathlib.Path(cacheDirLocation).mkdir(parents=True, exist_ok=True) - pathlib.Path(self._addonDownloadCacheDir).mkdir(parents=True, exist_ok=True) - pathlib.Path(self._installedAddonDataCacheDir).mkdir(parents=True, exist_ok=True) + + if NVDAState.shouldWriteToDisk(): + # ensure caching dirs exist + pathlib.Path(cacheDirLocation).mkdir(parents=True, exist_ok=True) + pathlib.Path(self._addonDownloadCacheDir).mkdir(parents=True, exist_ok=True) + pathlib.Path(self._installedAddonDataCacheDir).mkdir(parents=True, exist_ok=True) self._latestAddonCache = self._getCachedAddonData(self._cacheLatestFile) self._compatibleAddonCache = self._getCachedAddonData(self._cacheCompatibleFile)