summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Christoph Borchardt <hey@jancborchardt.net>2013-01-16 05:18:53 -0800
committerJan-Christoph Borchardt <hey@jancborchardt.net>2013-01-16 05:18:53 -0800
commitcb0fd30458c29db7667582b7c182b4d530366634 (patch)
tree25f49cf1fe666ed06ed8b75adf23acab7c56bc7d
parent2b9c925a2beaa345c7dc802af8acaac69d594e28 (diff)
parent44e5c052b3f4fdc352790aee982217a83f9449ef (diff)
downloadnextcloud-server-cb0fd30458c29db7667582b7c182b4d530366634.tar.gz
nextcloud-server-cb0fd30458c29db7667582b7c182b4d530366634.zip
Merge pull request #1185 from owncloud/fixing-1162-master
handling proper display of files/folders with negative size
-rw-r--r--lib/helper.php4
-rw-r--r--lib/template.php20
2 files changed, 19 insertions, 5 deletions
diff --git a/lib/helper.php b/lib/helper.php
index e7c9ac8015d..7f34d895821 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -223,6 +223,10 @@ class OC_Helper {
* Makes 2048 to 2 kB.
*/
public static function humanFileSize( $bytes ) {
+ if( $bytes < 0 ) {
+ $l = OC_L10N::get('lib');
+ return $l->t("couldn't be determined");
+ }
if( $bytes < 1024 ) {
return "$bytes B";
}
diff --git a/lib/template.php b/lib/template.php
index 04667d73a2c..f10a637346c 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -85,11 +85,21 @@ function human_file_size( $bytes ) {
}
function simple_file_size($bytes) {
- $mbytes = round($bytes/(1024*1024), 1);
- if($bytes == 0) { return '0'; }
- else if($mbytes < 0.1) { return '&lt; 0.1'; }
- else if($mbytes > 1000) { return '&gt; 1000'; }
- else { return number_format($mbytes, 1); }
+ if ($bytes < 0) {
+ return '?';
+ }
+ $mbytes = round($bytes / (1024 * 1024), 1);
+ if ($bytes == 0) {
+ return '0';
+ }
+ if ($mbytes < 0.1) {
+ return '&lt; 0.1';
+ }
+ if ($mbytes > 1000) {
+ return '&gt; 1000';
+ } else {
+ return number_format($mbytes, 1);
+ }
}
function relative_modified_date($timestamp) {