From 00afb2dc299f7cf417b60dfd59b3d8b4146a641b Mon Sep 17 00:00:00 2001 From: AlexKaravaev <30314738+AlexKaravaev@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:06:07 +0200 Subject: [PATCH] fix(hil): fix a bug with overwriting existing rts file (#273) --- hil/src/download_s3.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hil/src/download_s3.rs b/hil/src/download_s3.rs index 9586dd90..b9e15898 100644 --- a/hil/src/download_s3.rs +++ b/hil/src/download_s3.rs @@ -218,9 +218,15 @@ pub async fn download_url( "{out_path_clone:?} already exists!" ); } - tmp_file_path - .persist_noclobber(&out_path_clone) - .wrap_err("failed to persist temporary file") + if existing_file_behavior == ExistingFileBehavior::Abort { + tmp_file_path + .persist_noclobber(&out_path_clone) + .wrap_err("failed to persist temporary file") + } else { + tmp_file_path + .persist(&out_path_clone) + .wrap_err("failed to persist temporary file") + } }) .await .wrap_err("task panicked")??;