Skip to content

Commit

Permalink
Wait in get till no processes are using the output filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Nov 11, 2024
1 parent 449afbc commit 80075ae
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/scripts/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 80075ae

Please sign in to comment.