From df3f7f93e0b28a2bb28ac6bde45b30689ece801e Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Sun, 8 Mar 2009 20:42:20 -0700
Subject: [PATCH] storage.expirer: handle upgrades better

---
 src/allmydata/storage/expirer.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/allmydata/storage/expirer.py b/src/allmydata/storage/expirer.py
index 79254241..32913cb9 100644
--- a/src/allmydata/storage/expirer.py
+++ b/src/allmydata/storage/expirer.py
@@ -61,6 +61,10 @@ class LeaseCheckingCrawler(ShareCrawler):
         # get started: unit tests do this
         so_far = self.create_empty_cycle_dict()
         self.state.setdefault("cycle-to-date", so_far)
+        # in case we upgrade the code while a cycle is in progress, update
+        # the keys individually
+        for k in self.state["cycle-to-date"]:
+            self.state["cycle-to-date"].setdefault(k, so_far[k])
 
         # initialize history
         if not os.path.exists(self.historyfile):
-- 
2.45.2