From 2da8b98fffe15bc80717645646a1557ff0d428ef Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Thu, 15 Feb 2024 10:56:17 +0100 Subject: fs: check if writing md5sum to full.sum file fails writing to file might fail (permission denied, disk full), check for errors. --- src/live/ogOperations.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/live/ogOperations.py') diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index 0a75630..ea9f5cb 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -122,8 +122,14 @@ class OgLiveOperations: raise ValueError('Invalid image path when computing md5 checksum') filename = path + ".full.sum" dig = self._compute_md5(path) - with open(filename, 'w') as f: - f.write(dig) + try: + with open(filename, 'w') as f: + f.write(dig) + except: + logging.error(f'cannot write {filename}') + return -1 + + return 0 def _copy_image_to_cache(self, image_name): """ @@ -515,7 +521,9 @@ class OgLiveOperations: image_info.perms = perms image_info.mtime = mtime - self._write_md5_file(f'/opt/opengnsys/images/{name}.img') + if self._write_md5_file(f'/opt/opengnsys/images/{name}.img') == -1: + logging.error(f'cannot write {name}.full.sum file') + raise ValueError(f'Error: Cannot write {name}.full.sum file') self._restartBrowser(self._url) -- cgit v1.2.3-18-g5258