From 80075aeba5b10e39a9b591da5dcd89fefaf61b89 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 11 Nov 2024 14:32:06 +0530 Subject: [PATCH] Wait in get till no processes are using the output filepath --- src/scripts/unix.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/scripts/unix.sh b/src/scripts/unix.sh index 25ae845f..f6bf0845 100644 --- a/src/scripts/unix.sh +++ b/src/scripts/unix.sh @@ -89,6 +89,12 @@ get() { echo "Another process is downloading a file at $file_path, waiting" sleep 1 done + if [ "$execute" = "-e" ]; then + until [ -z "$(fuser "$file_path" 2>/dev/null)" ]; do + echo "Waiting for other processes to stop using $file_path..." + sleep 1 + done + fi trap 'sudo rm -rf "$lock_path"' EXIT SIGINT SIGTERM for link in "${links[@]}"; do status_code=$(sudo curl -w "%{http_code}" -o "$file_path" "${curl_opts[@]}" "$link")