bugfix: fix celery crashing, due to UPLOAD_DIR being deleted
Delete all dirs and files inside UPLOAD_DIR instead
This commit is contained in:
+8
-1
@@ -19,9 +19,16 @@ from freqsplit.input.format_checker import is_supported_format
|
|||||||
UPLOAD_DIR = "/tmp/freqsplit"
|
UPLOAD_DIR = "/tmp/freqsplit"
|
||||||
|
|
||||||
# Ensure the temp directory exists
|
# Ensure the temp directory exists
|
||||||
shutil.rmtree(UPLOAD_DIR)
|
|
||||||
os.makedirs(UPLOAD_DIR, exist_ok=True)
|
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
|
# Endpoint to ping server
|
||||||
@api_view(['GET'])
|
@api_view(['GET'])
|
||||||
def ping(request):
|
def ping(request):
|
||||||
|
|||||||
Reference in New Issue
Block a user