summaryrefslogtreecommitdiffstats
path: root/src/utils/tiptorrent.py
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/utils/tiptorrent.py
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/utils/tiptorrent.py')
-rw-r--r--src/utils/tiptorrent.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/utils/tiptorrent.py b/src/utils/tiptorrent.py
index 095f17f..7392725 100644
--- a/src/utils/tiptorrent.py
+++ b/src/utils/tiptorrent.py
@@ -6,7 +6,6 @@
# Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
-import hashlib
import logging
import os
import shlex
@@ -15,16 +14,7 @@ import subprocess
import urllib.request
from src.log import OgError
from src.utils.cache import *
-
-def _compute_md5(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()
+from src.utils.fs import compute_md5
def tip_fetch_csum(tip_addr, image_name):
@@ -64,7 +54,7 @@ def tip_write_csum(image_name):
logging.info('*DO NOT REBOOT OR POWEROFF* the client during this time')
filename = image_path + ".full.sum"
- csum = _compute_md5(image_path)
+ csum = compute_md5(image_path)
try:
with open(filename, 'w') as f:
f.write(csum)