From 6bfbf6cc7b8b5425eb8922769755a6c1cc2fb376 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Tue, 7 May 2024 17:03:26 +0200 Subject: utils: add error checks to checksum file creation in tip_write_csum Add a check for potential permission or IO errors during the creation of the image checksum. --- src/utils/tiptorrent.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/utils') diff --git a/src/utils/tiptorrent.py b/src/utils/tiptorrent.py index 1d628c1..9ed6a65 100644 --- a/src/utils/tiptorrent.py +++ b/src/utils/tiptorrent.py @@ -51,8 +51,11 @@ def tip_write_csum(image_name): filename = image_path + ".full.sum" csum = _compute_md5(image_path) - with open(filename, 'w') as f: - f.write(csum) + try: + with open(filename, 'w') as f: + f.write(csum) + except OSError as e: + raise OgError(f'Could not write {filename}, reported: {e}') from e return csum -- cgit v1.2.3-18-g5258