bugfix: fix celery crashing, due to UPLOAD_DIR being deleted

Delete all dirs and files inside UPLOAD_DIR instead
This commit is contained in:
Joel Mathew Thomas
2025-03-21 01:36:38 +05:30
parent c58ee4ca22
commit 38ecb59519
+8 -1
View File
@@ -19,9 +19,16 @@ from freqsplit.input.format_checker import is_supported_format
UPLOAD_DIR = "/tmp/freqsplit"
# Ensure the temp directory exists
shutil.rmtree(UPLOAD_DIR)
os.makedirs(UPLOAD_DIR, exist_ok=True)
# Remove all files inside the directory
for filename in os.listdir(UPLOAD_DIR):
file_path = os.path.join(UPLOAD_DIR, filename)
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
# Endpoint to ping server
@api_view(['GET'])
def ping(request):