mutable repairer: skip repair of readcaps instead of throwing an exception.

This should improve the behavior of #625 a bit: at least all the files will
get repaired.
This commit is contained in:
Brian Warner 2009-06-30 18:13:43 -07:00
parent 4194565b3d
commit e330abc3c3
2 changed files with 28 additions and 1 deletions

View File

@ -297,6 +297,11 @@ class MutableCheckAndRepairer(MutableChecker):
if not self.need_repair:
self.cr_results.post_repair_results = self.results
return
if self._node.is_readonly():
# ticket #625: we cannot yet repair read-only mutable files
self.cr_results.post_repair_results = self.results
self.cr_results.repair_attempted = False
return
self.cr_results.repair_attempted = True
d = self._node.repair(self.results)
def _repair_finished(repair_results):

View File

@ -12,7 +12,7 @@ from allmydata.util.idlib import shortnodeid_b2a
from allmydata.util.hashutil import tagged_hash
from allmydata.util.fileutil import make_dirs
from allmydata.interfaces import IURI, IMutableFileURI, IUploadable, \
NotEnoughSharesError, IRepairResults
NotEnoughSharesError, IRepairResults, ICheckAndRepairResults
from allmydata.monitor import Monitor
from allmydata.test.common import ShouldFailMixin
from foolscap.api import eventually, fireEventually
@ -1465,6 +1465,28 @@ class Repair(unittest.TestCase, PublishMixin, ShouldFailMixin):
unpack_header(share)
return root_hash
def test_check_and_repair_readcap(self):
# we can't currently repair from a mutable readcap: #625
self.old_shares = []
d = self.publish_one()
d.addCallback(self.copy_shares)
def _get_readcap(res):
self._fn3 = self._fn.get_readonly()
# also delete some shares
for peerid,shares in self._storage._peers.items():
shares.pop(0, None)
d.addCallback(_get_readcap)
d.addCallback(lambda res: self._fn3.check_and_repair(Monitor()))
def _check_results(crr):
self.failUnless(ICheckAndRepairResults.providedBy(crr))
# we should detect the unhealthy, but skip over mutable-readcap
# repairs until #625 is fixed
self.failIf(crr.get_pre_repair_results().is_healthy())
self.failIf(crr.get_repair_attempted())
self.failIf(crr.get_post_repair_results().is_healthy())
d.addCallback(_check_results)
return d
class MultipleEncodings(unittest.TestCase):
def setUp(self):
self.CONTENTS = "New contents go here"