Skip to content

Commit 80075ae

Browse files
committed
Wait in get till no processes are using the output filepath
1 parent 449afbc commit 80075ae

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/scripts/unix.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ get() {
8989
echo "Another process is downloading a file at $file_path, waiting"
9090
sleep 1
9191
done
92+
if [ "$execute" = "-e" ]; then
93+
until [ -z "$(fuser "$file_path" 2>/dev/null)" ]; do
94+
echo "Waiting for other processes to stop using $file_path..."
95+
sleep 1
96+
done
97+
fi
9298
trap 'sudo rm -rf "$lock_path"' EXIT SIGINT SIGTERM
9399
for link in "${links[@]}"; do
94100
status_code=$(sudo curl -w "%{http_code}" -o "$file_path" "${curl_opts[@]}" "$link")

0 commit comments

Comments
 (0)