[source] download.pl: check for existing file before the first download attempt

LEDE Commits lede-commits at lists.infradead.org
Fri Dec 16 06:16:53 PST 2016


nbd pushed a commit to source.git, branch master:
https://git.lede-project.org/651bc94df424faae586f0ad8ca0f0a4ef95e5090

commit 651bc94df424faae586f0ad8ca0f0a4ef95e5090
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Fri Dec 16 15:15:48 2016 +0100

    download.pl: check for existing file before the first download attempt
    
    In the build system, flock will prevent multiple concurrent downloads
    for the same file. However, if one download request for the same file is
    waiting for another one to finish, it will result in downloading the
    same file twice consecutively.
    
    Prevent this issue by exiting immediately if the file has already been
    downloaded
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 scripts/download.pl | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/download.pl b/scripts/download.pl
index 90d50a8..ab72b6b 100755
--- a/scripts/download.pl
+++ b/scripts/download.pl
@@ -246,12 +246,11 @@ push @mirrors, 'http://sources.lede-project.org';
 push @mirrors, 'http://mirror2.openwrt.org/sources';
 push @mirrors, 'http://downloads.openwrt.org/sources';
 
-while (!$ok) {
+while (!-f "$target/$filename") {
 	my $mirror = shift @mirrors;
 	$mirror or die "No more mirrors to try - giving up.\n";
 
 	download($mirror);
-	-f "$target/$filename" and $ok = 1;
 }
 
 $SIG{INT} = \&cleanup;



More information about the lede-commits mailing list