From 340b7fde54b4f57321e03761125eaefb2d77c684 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 26 Sep 2024 10:19:37 +0200 Subject: views: improve checks for space available in cache Use the new "free_cache" field in GET /cache/list to check against the real available space to check if an image fits in cache. --- ogcp/views.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'ogcp') diff --git a/ogcp/views.py b/ogcp/views.py index 5418018..edcc2ab 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -956,20 +956,17 @@ def image_fits_in_cache(server, clients_info, image): for client_info in clients_info: ip = client_info['ip'] - cache_size = int(client_info['cache_size']) - used_cache = 0 + cache_size = client_info['cache_size'] * 1024 has_image = False; for image_info in client_info['images']: - used_cache += int(image_info['size']) - if image_info['checksum'] == image_checksum: has_image = True if has_image: continue - free_cache = cache_size - used_cache + free_cache = client_info['free_cache'] if free_cache < image_size: missing_cache = image_size - free_cache err_report += f'{ip} requires {(missing_cache / (1024 ** 3)):.3f} free GiB
' -- cgit v1.2.3-18-g5258