}
} else { # download file from net
print "Downloading the $str file\n"; # download file
- $ua = LWP::UserAgent->new;
- $request = HTTP::Request->new(GET => "$url");
- $response = $ua->request($request, \&callback);
+ my $ua = LWP::UserAgent->new;
+ my $request = HTTP::Request->new(GET => "$url");
+ my $response = $ua->request($request, \&callback);
# cache retrieved file to disk
# <ZACK/> TODO: inefficent, I haven't yet undestood how to deflate
}
sub helm_wget {
-#ported from helm_wget executable, TODO: rewrite without wget.
#retrieve a file from an url and write it to a temp dir
-#used for retrieve resource indexe from servers
+#used for retrieve resource index from servers
+ $cont = "";
my ($prefix, $URL) = @_;
- if ($URL =~ /^file:\//) {
- $URL =~ s/^file:\///;
- my $command = "mkdir -p $prefix ; cp $URL $prefix";
- print "$command\n";
- system($command) == 0
- or die "\"$command\" error";
- } else {
- my $command = "wget -c -P $prefix $URL";
- system($command) == 0
- or die "\"$command\" error";
- }
+ my $ua = LWP::UserAgent->new;
+ my $request = HTTP::Request->new(GET => "$URL");
+ my $response = $ua->request($request, \&callback);
+ my ($filename) = reverse (split "/", $URL); # get filename part of the URL
+ open (TEMP, "> $prefix/$filename")
+ || die "Cannot open temporary file: $prefix/$filename\n";
+ print TEMP $cont;
+ close TEMP;
}
sub update {
while ($server = pop @servers) { #cicle on servers in reverse order
print "processing server: $server ...\n";
chomp $server;
- $debugserver = "http://dalamar.krynn.it/helm"; # FOR DEBUG ONLY: REMOVE ME !!
helm_wget($tmp_dir, $server."/".$indexname); #get index
$idxfile = $tmp_dir."/".$indexname;
open (INDEX, "< $idxfile") or