From 74c55987ef5662d666e0844b3e18c824cd9dcee2 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Mon, 17 Jun 2024 14:09:49 +0200 Subject: views: fix image restore cache checks Fix the scope of the has_cache variable to reset the value for each client. Check the partition type based on the PART_TYPE_CODES string version instead of the numerical value of the partition type. --- ogcp/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 0133954..886ff13 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -837,7 +837,6 @@ def action_image_restore(): for image in images[repo_id]: form.image.choices.append((image['id'], image['name'])) - has_cache = False part_choices = [] for ip in ips: r = server.get('/client/setup', payload={'client': [ip]}) @@ -846,6 +845,8 @@ def action_image_restore(): if r.status_code != requests.codes.ok: return ogserver_error('commands') + has_cache = False + partitions = r.json()['partitions'] parts = [] for partition in partitions: @@ -854,7 +855,7 @@ def action_image_restore(): if part_id == 0: # This is the disk data, not a partition. continue part_code = partition['code'] - if part_code == 'CACHE': + if PART_TYPE_CODES.get(int(part_code), 'UNKNOWN') == 'CACHE': has_cache = True filesystem = partition['filesystem'] part_size = partition['size'] -- cgit v1.2.3-18-g5258