From d605dc03d1d52e9b7acac97df0afc7f2c6b9647e Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Wed, 2 Oct 2019 12:47:06 +0100 Subject: Possibile to use download-multi-try script without locks Until now, this script would always only work with a file-lock. But in some scenarios, we might want to download in parallel. For example when the system has multiple ports to the internet. With this commit, we have added this feature: when the lockfile name is `nolock', it won't lock and will download in parallel. --- reproduce/analysis/bash/download-multi-try | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'reproduce/analysis') 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 # @@ -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 -- cgit v1.2.1