BackupPC-users

Re: [BackupPC-users] Changing backup browsing view from bytes to eg megabytes

2014-10-22 07:54:32
Subject: Re: [BackupPC-users] Changing backup browsing view from bytes to eg megabytes
From: Alexander Moisseev <moiseev AT mezonplus DOT ru>
To: backuppc-users AT lists.sourceforge DOT net
Date: Wed, 22 Oct 2014 15:52:59 +0400
It doesn't matter where "$a->{size}" comes from if you can change it right here.


root@backup:/usr/local/lib/BackupPC/CGI # diff -ruN Browse.pm.orig Browse.pm
--- Browse.pm.orig      2014-10-22 15:12:01.000000000 +0400
+++ Browse.pm   2014-10-22 15:38:50.000000000 +0400
@@ -206,11 +206,25 @@
                      $iconStr = <<EOF;
  <img src="$Conf{CgiImageDirURL}/icon-$typeStr.png" valign="top">
  EOF
+                    my $size;
+                    if ( $a->{size} >= 1073741824 ) {
+                        $size = sprintf( "%u GiB", $a->{size} / (1073741824) );
+                    }
+                    elsif ( $a->{size} >= 1048576 ) {
+                        $size = sprintf( "%u MiB", $a->{size} / 1048576 );
+                    }
+                    elsif ( $a->{size} >= 1024 ) {
+                        $size = sprintf( "%u KiB", $a->{size} / 1024 );
+                    }
+                    else {
+                        $size = $a->{size};
+                    }
+
                      $attrStr .= <<EOF;
      <td align="center" class="fviewborder">$typeStr</td>
      <td align="center" class="fviewborder">$modeStr</td>
      <td align="center" class="fviewborder">$a->{backupNum}</td>
-    <td align="right" class="fviewborder">$a->{size}</td>
+    <td align="right" class="fviewborder">$size</td>
      <td align="right" class="fviewborder">$mtimeStr</td>
  </tr>
  EOF

--
Alexander

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

<Prev in Thread] Current Thread [Next in Thread>