Skip to content

Commit

Permalink
network_cache_size_bytes == 0 will totally disable the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zas committed Apr 11, 2024
1 parent 40856d9 commit e6c65b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions picard/ui/options/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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))

Expand Down
3 changes: 3 additions & 0 deletions picard/webservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e6c65b7

Please sign in to comment.