More comments...
On 4/4/12 3:37 AM, Tathagata Das wrote: > 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; > + } > + } Close the file as soon as you're done with it. You're less likely to run out of file descriptors. > + 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; perldoc Digest::MD5 use Digest::MD5; my $ctx = Digest::MD5->new; open(FILE, "$target/$filename.dl") || die "can't open $target/$filename.dl"; binmode(FILE); $ctx->addfile(*FILE); close(FILE); my $digest = $ctx->hexdigest; open(DIGEST, ">$target/$filename.md5sum") || die "can't save md5sum for $target/$filename.mdsum"; print DIGEST, $digest, "\n"; close(DIGEST); > } 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