aboutsummaryrefslogtreecommitdiff
path: root/reproduce/analysis/bash/download-multi-try
diff options
context:
space:
mode:
Diffstat (limited to 'reproduce/analysis/bash/download-multi-try')
-rwxr-xr-xreproduce/analysis/bash/download-multi-try15
1 files changed, 11 insertions, 4 deletions
diff --git a/reproduce/analysis/bash/download-multi-try b/reproduce/analysis/bash/download-multi-try
index 03472b3..2ac106c 100755
--- a/reproduce/analysis/bash/download-multi-try
+++ b/reproduce/analysis/bash/download-multi-try
@@ -16,13 +16,15 @@
# it can't continue. The job of this script is to be patient and try the
# download multiple times before crashing the whole project.
#
-# LOCK FILE: Since there is ultimately only one network port to the outside
+# LOCK FILE: Since there is usually only one network port to the outside
# world, downloading is done much faster in serial, not in parallel. But
# the project's processing may be done in parallel (with multiple threads
# needing to download different files at the same time). Therefore, this
# script uses the `flock' program to only do one download at a time. To
# benefit from it, any call to this script must be given the same lock
-# file.
+# file. If your system has multiple ports to the internet, or for any
+# reason, you don't want to use a lock file, set the `lockfile' name to
+# `nolock'.
#
# Copyright (C) 2019 Mohammad Akhlaghi <mohammad@akhlaghi.org>
#
@@ -102,8 +104,13 @@ while [ ! -f "$outname" ]; do
# `downloader' ends with the respective option to specify the output
# name. For example "wget -O" (so `outname', that comes after it) will
# be the name of the downloaded file.
- flock "$lockfile" bash -c \
- "if ! $downloader $outname $inurl; then rm -f $outname; fi"
+ if [ x"$lockfile" = xnolock ]; then
+ if ! $downloader $outname $inurl; then rm -f $outname; fi
+ else
+ flock "$lockfile" bash -c \
+ "if ! $downloader $outname $inurl; then rm -f $outname; fi"
+ fi
+
done