From 106d31b1122689f1f58ed83eb5e06b4949feb835 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Fri, 20 Feb 2009 21:58:31 -0700
Subject: [PATCH] BucketCountingCrawler: store just the count, not cycle+count,
 since it's too easy to make usage mistakes otherwise

---
 src/allmydata/storage/crawler.py | 2 +-
 src/allmydata/storage/server.py  | 3 +--
 src/allmydata/web/storage.py     | 5 ++---
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/allmydata/storage/crawler.py b/src/allmydata/storage/crawler.py
index d6c342fb..89d4407d 100644
--- a/src/allmydata/storage/crawler.py
+++ b/src/allmydata/storage/crawler.py
@@ -373,7 +373,7 @@ class BucketCountingCrawler(ShareCrawler):
         if len(last_counts) == len(self.prefixes):
             # great, we have a whole cycle.
             num_buckets = sum(last_counts.values())
-            self.state["last-complete-bucket-count"] = (cycle, num_buckets)
+            self.state["last-complete-bucket-count"] = num_buckets
             # get rid of old counts
             for old_cycle in list(self.state["bucket-counts"].keys()):
                 if old_cycle != cycle:
diff --git a/src/allmydata/storage/server.py b/src/allmydata/storage/server.py
index f0db0a54..1604b10e 100644
--- a/src/allmydata/storage/server.py
+++ b/src/allmydata/storage/server.py
@@ -173,8 +173,7 @@ class StorageServer(service.MultiService, Referenceable):
         s = self.bucket_counter.get_state()
         bucket_count = s.get("last-complete-bucket-count")
         if bucket_count:
-            cycle, count = bucket_count
-            stats["storage_server.total_bucket_count"] = count
+            stats["storage_server.total_bucket_count"] = bucket_count
         return stats
 
 
diff --git a/src/allmydata/web/storage.py b/src/allmydata/web/storage.py
index f3dd37c6..6cff994a 100644
--- a/src/allmydata/web/storage.py
+++ b/src/allmydata/web/storage.py
@@ -65,10 +65,9 @@ class StorageStatus(rend.Page):
 
     def data_last_complete_bucket_count(self, ctx, data):
         s = self.storage.bucket_counter.get_state()
-        lcbc = s.get("last-complete-bucket-count")
-        if lcbc is None:
+        count = s.get("last-complete-bucket-count")
+        if count is None:
             return "Not computed yet"
-        cycle, count = lcbc
         return count
 
     def render_count_crawler_status(self, ctx, storage):
-- 
2.45.2