Inline...
On 4/2/12 6:06 AM, Tathagata Das wrote:
> Hi,
> I have modified the patch as John suggested. This patch will only copy a
> single file from local repository. If more than one instance of the same file
> exists in the subfolders then it will throw an error. I have used latest
> trunk (revision 31050) to test this patch.
>
> Thanks John for your feedback.
>
> Signed-off-by: Tathagata Das <[email protected]>
>
> ---
>
> diff -Naur a/scripts/download.pl b/scripts/download.pl
> --- a/scripts/download.pl 2012-03-05 10:44:02.000000000 +0530
> +++ b/scripts/download.pl 2012-04-02 17:31:28.000000000 +0530
> @@ -74,7 +74,18 @@
> 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 1>>
> temp.dls");
You don't need "1>>" since '1' is the default.
> + my $lines = `cat temp.dls | wc -l`;
Perl isn't a wrapper for bash. You can slurp a file and get the record count
without needing 2 extra processes to do so.
> + if ($lines != 1 ) {
> + system("echo Error : Number of instances of $filename
> in $cache is $lines");
> + system("echo Only one instance allowed.");
> + system("rm -f temp.dls");
You don't need an extra process for this. You can do:
unlink("temp.dls");
instead.
> + return;
> + }
> + else {
> + system("cat temp.dls | xargs -i cp -vf {}
> $target/$filename.dl");
> + system("rm -f temp.dls");
Ditto.
> + }
> system("$md5cmd $target/$filename.dl >
> \"$target/$filename.md5sum\" ") == 0 or return;
Why are you quoting filenames in some places but not others?
> } else {
> open WGET, "wget -t5 --timeout=20 --no-check-certificate
> $options -O- \"$mirror/$filename\" |" or die "Cannot launch wget.\n";
>
>
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel