From 2cecfcdfdb0cce0a74ca8cff944b6f17fa175b88 Mon Sep 17 00:00:00 2001 From: Fledge Shiu Date: Wed, 23 Aug 2023 10:53:39 -0400 Subject: [PATCH] Delete local files after successful upload --- backend/api/routes/files.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/api/routes/files.py b/backend/api/routes/files.py index 0b51288d..ebc79f27 100644 --- a/backend/api/routes/files.py +++ b/backend/api/routes/files.py @@ -174,8 +174,9 @@ def upload_file_to_s3(new_file: File): for i in range(constants.s3_max_tries): try: - s3_storage.storage.upload_file(fpath=new_file.path, key=s3_key) + s3_storage.storage.upload_file(fpath=new_file.local_fpath, key=s3_key) update_file_status_and_path(new_file, FileStatus.S3, s3_key) + new_file.local_fpath.unlink(missing_ok=True) return except Exception as exc: logger.error(f"{new_file.hash} failed to upload to cache: {exc}")