Hi, I have updated the patch as Philip and Jo-Philipp suggested. Thanks Philip and Jo-Philipp for your feedback.
Signed-off-by: Tathagata Das <tathag...@alumnux.com> --- diff -Naur a/scripts/download.pl b/scripts/download.pl --- a/scripts/download.pl 2012-04-04 13:19:27.000000000 +0530 +++ b/scripts/download.pl 2012-04-04 13:20:34.000000000 +0530 @@ -9,6 +9,7 @@ use strict; use warnings; use File::Basename; +use File::Copy; @ARGV > 2 or die "Syntax: $0 <target dir> <filename> <md5sum> [<mirror> ...]\n"; @@ -74,7 +75,29 @@ if(! -d $target) { system("mkdir -p $target/"); } - system("cp -vf $cache/$filename $target/$filename.dl") == 0 or return; + system("find $cache -follow -name $filename 2>/dev/null >> temp.dls"); + open TMPDLS,"temp.dls" and do { + my $i = 0; + my $link = ""; + while (<TMPDLS>) { + $link = $_; + chomp $link; + $i++; + if ($i > 1) { + print("$i or more instances of $filename in $cache found . Only one instance allowed.\n"); + last; + } + } + if ($i < 1) { + print("No instances of $filename found in $cache.\n"); + } + if ($i == 1){ + print("Copying $link.\n"); + copy($link, "$target/$filename.dl"); + } + unlink("temp.dls") or print("Falied to delete the temporary file\n"); + close TMPDLS; + }; system("$md5cmd $target/$filename.dl > \"$target/$filename.md5sum\" ") == 0 or return; } else { open WGET, "wget -t5 --timeout=20 --no-check-certificate $options -O- \"$mirror/$filename\" |" or die "Cannot launch wget.\n"; _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel