From ab0f48f3514272725e074e15686e9cd0bccb71a2 Mon Sep 17 00:00:00 2001 From: tkucherera Date: Tue, 22 Oct 2024 12:05:23 -0400 Subject: [PATCH] enable ability to clean up assets --- confluent_server/confluent/core.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 528c3f21..48af7b70 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -72,6 +72,7 @@ import struct import sys import uuid import yaml +import shutil pluginmap = {} @@ -1308,8 +1309,14 @@ class Staging: file = None return False - def deldirectory(self): - pass + @staticmethod + def remove_directory(directory): + storage_folder = '/var/lib/confluent/client_assets/' + directory + if os.path.exists(storage_folder): + shutil.rmtree(storage_folder) + else: + raise FileNotFoundError + return directory def handle_staging(pathcomponents, operation, configmanager, inputdata): ''' @@ -1348,9 +1355,12 @@ def handle_staging(pathcomponents, operation, configmanager, inputdata): yield msg.FileUploadProgress(100) - elif operation == 'retrieve': - pass - return + elif operation == 'delete': + if len(pathcomponents) == 3: + asset = Staging.remove_directory(pathcomponents[2]) + yield msg.DeletedResource(asset) + else: + raise Exception("Invalid url") def handle_path(path, operation, configmanager, inputdata=None, autostrip=True): """Given a full path request, return an object.