Skip to content

Commit

Permalink
Delete local files after successful upload
Browse files Browse the repository at this point in the history
  • Loading branch information
FledgeXu committed Aug 23, 2023
1 parent d47a8d5 commit 2cecfcd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/api/routes/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit 2cecfcd

Please sign in to comment.