From dd003e688fad500bb40210d64b7b96e1ea63b8fa Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Mon, 27 May 2024 10:55:59 +0200 Subject: tiptorrent: check cache availability in tip_write_csum Remove old TODO message. Check if the cache is available before trying to generate an image's checksum. --- src/utils/tiptorrent.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/tiptorrent.py b/src/utils/tiptorrent.py index 9ed6a65..9715b21 100644 --- a/src/utils/tiptorrent.py +++ b/src/utils/tiptorrent.py @@ -14,6 +14,7 @@ import shutil import subprocess import urllib.request from src.log import OgError +from src.utils.cache import mount_cache def _compute_md5(path, bs=2**20): m = hashlib.md5() @@ -41,9 +42,9 @@ def tip_fetch_csum(tip_addr, image_name): def tip_write_csum(image_name): - """ - TODO: Check for CACHE partition - """ + if not mount_cache(): + raise OgError(f'Failed to checksum {image_name}: cache partition is not available') + image_path = f'/opt/opengnsys/cache/opt/opengnsys/images/{image_name}.img' if not os.path.exists(image_path): -- cgit v1.2.3-18-g5258