summaryrefslogtreecommitdiffstats
path: root/src/live/ogOperations.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/live/ogOperations.py')
-rw-r--r--src/live/ogOperations.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index 6948d98..d557fac 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -576,6 +576,46 @@ class OgLiveOperations:
logging.info('Image creation command OK')
return image_info
+ def cache_delete(self, request, ogRest):
+ images = request.getImages()
+ deleted_images = []
+
+ if not mount_cache():
+ return
+
+ 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
+ if os.sep in file_name:
+ logging.info(f'Detected cache deletion request of filename with a path, ignoring {file_name}')
+ continue
+
+ if file_name in images:
+ os.remove(file_path)
+
+ csum_path = file_path + '.full.sum'
+ if not os.path.isfile(csum_path):
+ logging.info(f'Missing checksum file for {file_path}')
+ continue
+
+ os.remove(csum_path)
+
+ result = {'cache': self._get_cache_contents()}
+
+ self._restartBrowser(self._url)
+
+ logging.info('Sending response to cache/delete request')
+ return result
+
def refresh(self, ogRest):
self._restartBrowser(self._url_log)