$bfile = basename("$file");
my $ua = LWP::UserAgent->new;
- $ua->agent('Pakfire/2.1');
+ $ua->agent('Pakfire/$Conf::version');
#$ua->timeout(5);
#$ua->env_proxy;
$proto = $templine[0];
$host = $templine[1];
$path = $templine[2];
- if ((pinghost("$host")) && testhost("$host") ) {
+ if (pinghost("$host")) {
$found = 1;
return ($proto, $host, $path);
}
}
}
-sub addsizes {
+sub addsizes { ## Still not working
my @paks = shift;
- my @sizes;
- foreach (@paks) {
- my $paksize = getsize("$_");
- push(@sizes, $paksize);
- }
-
+ my $paksize;
my $totalsize = 0;
- foreach (@sizes) {
- $totalsize += $_;
+ foreach (@paks) {
+ $paksize = getsize("$_");
+ $totalsize = ($totalsize + $paksize) ;
}
return $totalsize;
}
exit 1;
}
- message("\n## Downloading $file...");
+ #message("\n## Downloading $file...");
unless ( "$force" eq "force" ) {
if ( -e "$Conf::cachedir/$file" ) {
- message("$file is already there. Skipping download.");
return $file;
}
}
exit $return;
}
- exit $return;
+ return $return;
}
sub updatepak {
sub beautifysize {
my $size = shift;
+ $size = $size / 1024;
+ my $unit;
if ($size > 1023) {
- my $newsize = $size / 1024;
- return "$newsize MB";
+ $size = ($size / 1024);
+ $unit = "MB";
} else {
- return "$size KB";
+ $unit = "KB";
}
+ $size = sprintf("%.2f" , $size);
+ my $string = "$size $unit";
+ return $string;
}