Finally, size display should be working correctly
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 19 Jan 2009 22:57:57 +0000 (15:57 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 20 Jan 2009 05:05:29 +0000 (22:05 -0700)
imp/lib/Contents.php

index caf1f8e..57ccfc2 100644 (file)
@@ -517,7 +517,7 @@ class IMP_Contents
         if (($mask & self::SUMMARY_BYTES) ||
             $download_zip ||
             ($mask & self::SUMMARY_SIZE)) {
-            $part['bytes'] = $mime_part->getBytes();
+            $part['bytes'] = $size = $mime_part->getBytes();
 
             if ($part['bytes'] &&
                 ($mime_part->getCurrentEncoding() == 'base64')) {
@@ -525,13 +525,12 @@ class IMP_Contents
                  * only about 33 percent larger than the unencoded data."
                  * Thus, adding 33% to the byte size is a good estimate for
                  * our purposes. */
-                $size = number_format(max((($part['bytes'] * 0.75) / 1024), 1));
-            } else {
-                $size = $mime_part->getSize(true);
+                $size *= 1.33;
             }
-            $part['size'] = ($size > 1024)
-                ? sprintf(_("%s MB"), number_format(max(($size / 1024))))
-                : sprintf(_("%s KB"), max(round($size), 1));
+
+            $part['size'] = ($size > 1048576)
+                ? sprintf(_("%s MB"), number_format($size / 1048576, 1))
+                : sprintf(_("%s KB"), max(round($size / 1024), 1));
         }
 
         /* Get part's icon. */