Better cope with null values in the segments_used table.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Mon, 14 Jul 2008 21:17:57 +0000 (14:17 -0700)
committerMichael Vrable <mvrable@turin.ucsd.edu>
Mon, 14 Jul 2008 21:17:57 +0000 (14:17 -0700)
Treat nulls utilization values as 0.0 for cleaning purposes.  These
shouldn't come up, but may have been generated due to bugs in the SQLite
library, so deal gracefully with them instead of failing with an exception.

lbs.py

diff --git a/lbs.py b/lbs.py
index ee4f445..b8de982 100644 (file)
--- a/lbs.py
+++ b/lbs.py
@@ -583,9 +583,11 @@ class LocalDatabase:
             info.mtime = row[3]
             info.age_days = row[4]
 
-            # If age is not available for whatever reason, treat it as 0.0.
+            # If data is not available for whatever reason, treat it as 0.0.
             if info.age_days is None:
                 info.age_days = 0.0
+            if info.used_bytes is None:
+                info.used_bytes = 0.0
 
             # Benefit calculation: u is the estimated fraction of each segment
             # which is utilized (bytes belonging to objects still in use