Packages::DoDownload: Don't try to numerically compare a localized number
authorFrank Lichtenheld <frank@lichtenheld.de>
Mon, 3 Sep 2007 22:52:20 +0000 (00:52 +0200)
committerFrank Lichtenheld <frank@lichtenheld.de>
Mon, 3 Sep 2007 22:52:20 +0000 (00:52 +0200)
After formatting a number with the help of sprintf, it is localized, i.e.
the decimal point might not be a decimal point anymore. So don't try to
compare it numerically (i.e. with '<' or '>') since that will not work.

lib/Packages/DoDownload.pm

index 7c59272085c3db58e923c24562ae5be720c3b128..bc7dbab0e6d57a78783f81ede244f65e76cc6876 100644 (file)
@@ -85,9 +85,11 @@ sub do_download {
            $page_content->{archive} = $archive;
            $page_content->{suite} = $suite;
            $page_content->{pkg} = $pkg;
-           $page_content->{pkgsize} = sprintf( '%.1f', floor(($data{size}/102.4)+0.5)/10 );
-           $page_content->{pkgsize_unit} = _g( 'kByte' );
-           if ($page_content->{pkgsize} > 1024) {
+           my $pkgsize = floor(($data{size}/102.4)+0.5)/10;
+           if ($pkgsize < 1024) {
+               $page_content->{pkgsize} = sprintf( '%.1f', $pkgsize );
+               $page_content->{pkgsize_unit} = _g( 'kByte' );
+           } else {
                $page_content->{pkgsize} = sprintf( '%.1f', floor(($data{size}/(102.4*102.4))+0.5)/100 );
                $page_content->{pkgsize_unit} = _g( 'MByte' );
            }