From e6c65b7f52f87873a4afc97f597a7e00fafb912b Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Thu, 11 Apr 2024 10:34:23 +0200 Subject: [PATCH] network_cache_size_bytes == 0 will totally disable the cache --- picard/ui/options/network.py | 4 ++-- picard/webservice/__init__.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/picard/ui/options/network.py b/picard/ui/options/network.py index 2a8e0829e4..a81d1f1b6b 100644 --- a/picard/ui/options/network.py +++ b/picard/ui/options/network.py @@ -113,7 +113,7 @@ def display2cachesize(self, config): cache_size = int(self.ui.network_cache_size.text()) except ValueError: return - if cache_size > 0: + if cache_size >= 0: config.setting['network_cache_size_bytes'] = int(cache_size * CACHE_SIZE_DISPLAY_UNIT) def cachesize2display(self, config): @@ -123,7 +123,7 @@ def cachesize2display(self, config): cache_size = -1 value = int(cache_size / CACHE_SIZE_DISPLAY_UNIT) - if cache_size <= 0: + if cache_size < 0: value = CACHE_SIZE_IN_BYTES self.ui.network_cache_size.setText(str(value)) diff --git a/picard/webservice/__init__.py b/picard/webservice/__init__.py index 8c2b08ecfa..4a40260761 100644 --- a/picard/webservice/__init__.py +++ b/picard/webservice/__init__.py @@ -392,6 +392,9 @@ def _init_timers(self): def set_cache(self, cache_size_in_bytes=None): if cache_size_in_bytes is None: cache_size_in_bytes = CACHE_SIZE_IN_BYTES + if cache_size_in_bytes <= 0: + log.debug("NetworkDiskCache disabled") + return cache = QtNetwork.QNetworkDiskCache() cache.setCacheDirectory(os.path.join(appdirs.cache_folder(), 'network')) cache.setMaximumCacheSize(cache_size_in_bytes)