From 70d27cfa7ce0af2345bb6113aba33810bf95a9ea Mon Sep 17 00:00:00 2001
From: kevan <kevan@isnotajoke.com>
Date: Sat, 24 Sep 2011 17:43:05 -0700
Subject: [PATCH] mutable/publish: handle unknown mutable share formats when
 handling errors

---
 src/allmydata/mutable/publish.py | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/allmydata/mutable/publish.py b/src/allmydata/mutable/publish.py
index edd30e48..8e4ef514 100644
--- a/src/allmydata/mutable/publish.py
+++ b/src/allmydata/mutable/publish.py
@@ -1102,28 +1102,35 @@ class Publish:
             self.surprised = True
             self.bad_peers.add(writer) # don't ask them again
             # use the checkstring to add information to the log message
+            unknown_format = False
             for (shnum,readv) in read_data.items():
                 checkstring = readv[0]
                 version = get_version_from_checkstring(checkstring)
                 if version == MDMF_VERSION:
                     (other_seqnum,
                      other_roothash) = unpack_mdmf_checkstring(checkstring)
-                else:
+                elif version == SDMF_VERSION:
                     (other_seqnum,
                      other_roothash,
                      other_salt) = unpack_sdmf_checkstring(checkstring)
+                else:
+                    unknown_format = True
                 expected_version = self._servermap.version_on_peer(peerid,
                                                                    shnum)
                 if expected_version:
                     (seqnum, root_hash, IV, segsize, datalength, k, N, prefix,
                      offsets_tuple) = expected_version
-                    self.log("somebody modified the share on us:"
-                             " shnum=%d: I thought they had #%d:R=%s,"
-                             " but testv reported #%d:R=%s" %
-                             (shnum,
-                              seqnum, base32.b2a(root_hash)[:4],
-                              other_seqnum, base32.b2a(other_roothash)[:4]),
-                             parent=lp, level=log.NOISY)
+                    msg = ("somebody modified the share on us:"
+                           " shnum=%d: I thought they had #%d:R=%s," %
+                           (shnum,
+                            seqnum, base32.b2a(root_hash)[:4]))
+                    if unknown_format:
+                        msg += (" but I don't know how to read share"
+                                " format %d" % version)
+                    else:
+                        msg += " but testv reported #%d:R=%s" % \
+                               (other_seqnum, other_roothash)
+                    self.log(msg, parent=lp, level=log.NOISY)
                 # if expected_version==None, then we didn't expect to see a
                 # share on that peer, and the 'surprise_shares' clause above
                 # will have logged it.
-- 
2.45.2