From: Andrew Ruthven <andrew@etc.gen.nz>
Date: Sun, 27 Oct 2013 18:40:24 +0000 (+1300)
Subject: Add a guard when calculating the disk percentage used.
X-Git-Tag: 0.10.4~6
X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0149de55c47e67219cd66bf9d18b9ee3ff076c0a;p=mythtv-status.git

Add a guard when calculating the disk percentage used.
---

diff --git a/ChangeLog b/ChangeLog
index 8c0e912..6e99f72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2013-10-28	Andrew Ruthven
+        Guard against zero total disk space, this affected Werner Mahr.
+
 2013-10-27	Andrew Ruthven
 	Handle the handling in POD in Perl 5.18. Force the return code
 	=item lines to be handled correctly.
diff --git a/bin/mythtv-status b/bin/mythtv-status
index 4291646..151b0f3 100755
--- a/bin/mythtv-status
+++ b/bin/mythtv-status
@@ -1063,8 +1063,15 @@ sub calc_disk_space_percentage {
     return 'unknown';
   }
 
+  # Guard against zero disk space.
+  $total = normalise_disk_space($total);
+  if ($total == 0) {
+    warn "Total disk space is 0 MB, I can't use that to calculate a percentage!\n";
+    return 'unknown';
+  }
+
   my $percent = sprintf("%.1f",
-    normalise_disk_space($used) / normalise_disk_space($total) * 100);
+    normalise_disk_space($used) / $total * 100);
 
   if ($percent >= $c->{'disk_space_warn'}) {
     $exit_value ||= 1;
diff --git a/debian/changelog b/debian/changelog
index 08fbe47..4ac5457 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,10 @@
 mythtv-status (0.10.4) unstable; urgency=low
 
-  * New upstream release (Closes: #724166, #709377).
+  * New upstream release (Closes: #724166, #709377, #709449).
   * Remove an extraneous hypen in our postinst (Cloases: #704436)
     Thank you Francois Marier for the patch.
 
- -- Andrew Ruthven <andrew@etc.gen.nz>  Sun, 27 Oct 2013 23:23:08 +1300
+ -- Andrew Ruthven <andrew@etc.gen.nz>  Mon, 28 Oct 2013 07:39:55 +1300
 
 mythtv-status (0.10.3) unstable; urgency=low