summaryrefslogtreecommitdiffstats
path: root/src/live
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-02 14:50:14 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-10-02 14:50:14 +0200
commit0f167cf29fd51b9e95146c4e93dd0f046e82de44 (patch)
tree510d00f8f5b024c0e6c397d888c96b16f8188d5b /src/live
parentcc70274079a0de78497011e2c665838522b6e1f5 (diff)
src: consolidate compute_md5 functions
Add compute_md5 function in src/utils/fs.py Remove identical md5 functions from src/live/ogOperations.py and src/utils/tiptorrent.py Move error checks from ogOperations.py into compute_md5 function in src/utils/fs.py
Diffstat (limited to 'src/live')
-rw-r--r--src/live/ogOperations.py18
1 files changed, 1 insertions, 17 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index 83242d2..f1478c3 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -200,22 +200,6 @@ class OgLiveOperations:
return data
- def _compute_md5(self, path, bs=2**20):
- m = hashlib.md5()
- with open(path, 'rb') as f:
- while True:
- buf = f.read(bs)
- if not buf:
- break
- m.update(buf)
- return m.hexdigest()
-
- def _md5_file(self, path):
- if not os.path.exists(path):
- raise OgError(f'Failed to calculate checksum, image file {path} does not exist')
-
- return self._compute_md5(path)
-
def _write_md5_file(self, path, checksum):
if not os.path.exists(path):
raise OgError(f'Failed to calculate checksum, image file {path} does not exist')
@@ -725,7 +709,7 @@ class OgLiveOperations:
logging.info(f'Writing checksum file {name}.img.full.sum...')
logging.info('*DO NOT REBOOT OR POWEROFF* the client during this time')
- checksum = self._md5_file(f'/opt/opengnsys/images/{name}.img')
+ checksum = compute_md5(f'/opt/opengnsys/images/{name}.img')
if checksum == -1:
raise OgError(f'Cannot access {name}.full.sum file')