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.
master 1.1.3-22
Alejandro Sirgo Rica 2024-06-17 14:09:49 +02:00
parent 4a74de1064
commit 74c55987ef
1 changed files with 3 additions and 2 deletions

View File

@ -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']