summaryrefslogtreecommitdiffstats
path: root/src/live
diff options
context:
space:
mode:
Diffstat (limited to 'src/live')
-rw-r--r--src/live/ogOperations.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index d4ac84e..6948d98 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -29,7 +29,7 @@ from src.utils.menu import generate_menu
from src.utils.fs import *
from src.utils.probe import os_probe, get_cache_dev_path
from src.utils.disk import *
-from src.utils.cache import generate_cache_txt, umount_cache, init_cache
+from src.utils.cache import *
from src.utils.tiptorrent import *
from src.utils.uefi import *
from src.utils.boot import *
@@ -111,6 +111,44 @@ class OgLiveOperations:
part_setup['filesystem'] = 'CACHE'
part_setup['code'] = 'ca'
+ def _get_cache_contents(self):
+ cache_contents = []
+
+ if not mount_cache():
+ return cache_contents
+
+ img_dir = OG_CACHE_IMAGE_PATH
+
+ if not os.path.isdir(img_dir):
+ return cache_contents
+
+ for file_name in os.listdir(img_dir):
+ file_path = os.path.join(img_dir, file_name)
+
+ if not os.path.isfile(file_path):
+ continue
+ if not file_name.endswith('.img'):
+ continue
+
+ checksum_file_path = file_path + '.full.sum'
+ image_checksum = ''
+
+ try:
+ with open(checksum_file_path, 'r') as f:
+ image_checksum = f.read()
+ except (FileNotFoundError, PermissionError, OSError) as e:
+ logging.info(f'Error reading file at {checksum_file_path}: {e}')
+
+ if not image_checksum:
+ logging.info(f'Warning: empty checksum for image {file_name}')
+
+ image_size = os.stat(file_path).st_size
+ cache_contents.append({
+ 'name': file_name,
+ 'size': image_size,
+ 'checksum': image_checksum})
+ return cache_contents
+
def _compute_md5(self, path, bs=2**20):
m = hashlib.md5()
with open(path, 'rb') as f:
@@ -568,6 +606,8 @@ class OgLiveOperations:
self._refresh_part_setup_cache(cxt, pa, part_setup, cache)
json_body['partition_setup'].append(part_setup)
+ json_body['cache'] = self._get_cache_contents()
+
generate_menu(json_body['partition_setup'])
generate_cache_txt()
self._restartBrowser(self._url)