summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2024-02-15 10:56:17 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-02-15 16:58:51 +0100
commit2da8b98fffe15bc80717645646a1557ff0d428ef (patch)
tree398df59ebaf05262ea67175aa817b8dcd12ad2f9
parent8fb8a0a66dabb5675cc82b37adfd14d00fda6f40 (diff)
fs: check if writing md5sum to full.sum file fails
writing to file might fail (permission denied, disk full), check for errors.
-rw-r--r--src/live/ogOperations.py14
1 files changed, 11 insertions, 3 deletions
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)