views: check if image fits in cache before /cache/fetch

Check if the image fits in cache before a /cache/fetch request.
Report the clients unable to store the image.
master
Alejandro Sirgo Rica 2024-09-26 10:21:19 +02:00
parent 340b7fde54
commit 77a60b717a
1 changed files with 11 additions and 0 deletions

View File

@ -1411,6 +1411,17 @@ def action_image_fetch():
flash(_(f'Image to fetch was not found'), category='error')
return redirect(url_for('commands'))
r = server.get('/cache/list', payload={'clients': ips})
if not r:
return ogserver_down('commands')
if r.status_code != requests.codes.ok:
return ogserver_error('commands')
clients_info = r.json()['clients']
if not image_fits_in_cache(server, clients_info, image):
return redirect(url_for('commands'))
payload = {'clients': ips,
'repository_id': image['repo_id'],
'type': form.method.data,