From 397e4f2c99a9da84fba8aba3e61a7adf1abfd154 Mon Sep 17 00:00:00 2001 From: Joel Mathew Thomas <90510078+joelmathewthomas@users.noreply.github.com> Date: Thu, 20 Mar 2025 00:17:40 +0530 Subject: [PATCH] remove file_uuid.zip file on websocket disconnect --- api/api/consumers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/api/consumers.py b/api/api/consumers.py index 2b517c7..b53ebca 100644 --- a/api/api/consumers.py +++ b/api/api/consumers.py @@ -34,8 +34,12 @@ class MediaConsumer(WebsocketConsumer): print("Stored file UUIDs:", self.file_uuid) for file_uuid in self.file_uuid: dir_path = os.path.join(UPLOAD_DIR, file_uuid); + zip_path = os.path.join(UPLOAD_DIR, f"{file_uuid}.zip") try: if os.path.exists(dir_path): shutil.rmtree(dir_path) + + if os.path.isfile(zip_path): + os.remove(zip_path) except Exception as e: - print(f"Error: Failed to cleanup {dir_path}: {e}") \ No newline at end of file + print(f"Error: Failed to cleanup {dir_path} or {zip_path}: {e}") \ No newline at end of file