]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
disallow deep-check on non-directories, simplifies the code a bit
authorBrian Warner <warner@allmydata.com>
Wed, 10 Sep 2008 20:44:58 +0000 (13:44 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 10 Sep 2008 20:44:58 +0000 (13:44 -0700)
docs/webapi.txt
src/allmydata/dirnode.py
src/allmydata/immutable/filenode.py
src/allmydata/interfaces.py
src/allmydata/mutable/node.py
src/allmydata/test/test_filenode.py
src/allmydata/test/test_system.py

index cfc3611d89605762a6dc8c4ba5e3053d763b2297..b558fda7f2624f167ef64029c455751bd85752b3 100644 (file)
@@ -729,9 +729,9 @@ POST $URL?t=deep-check
   page will contain a summary of the results, including details on any
   file/directory that was not fully healthy.
 
-  t=deep-check is most useful to invoke on a directory. If invoked on a file,
-  it will just check that single object. The recursive walker will deal with
-  loops safely.
+  t=deep-check can only be invoked on a directory. An error (400 BAD_REQUEST)
+  will be signalled if it is invoked on a file. The recursive walker will
+  deal with loops safely.
 
   This accepts the same verify=, when_done=, and return_to= arguments as
   t=check.
@@ -801,6 +801,10 @@ POST $URL?t=deep-check&repair=true
   This triggers a recursive walk of all files and directories, performing a
   t=check&repair=true on each one.
 
+  Like t=deep-check without the repair= argument, this can only be invoked on
+  a directory. An error (400 BAD_REQUEST) will be signalled if it is invoked
+  on a file. The recursive walker will deal with loops safely.
+
   This accepts the same when_done=URL, return_to=URL, and verify=true
   arguments as t=deep-check. When an output=JSON argument is provided, the
   response will contain the following keys:
index 3b3fbaee3022a93ded186b69de2cac1bcd5f0cd5..6945bdec2c85f1a006f0d0a53363cdc5e00cfacd 100644 (file)
@@ -8,7 +8,7 @@ from allmydata.mutable.common import NotMutableError
 from allmydata.mutable.node import MutableFileNode
 from allmydata.interfaces import IMutableFileNode, IDirectoryNode,\
      IURI, IFileNode, IMutableFileURI, IFilesystemNode, \
-     ExistingChildError, ICheckable
+     ExistingChildError, ICheckable, IDeepCheckable
 from allmydata.checker_results import DeepCheckResults, \
      DeepCheckAndRepairResults
 from allmydata.util import hashutil, mathutil, base32, log
@@ -114,7 +114,7 @@ class Adder:
         return new_contents
 
 class NewDirectoryNode:
-    implements(IDirectoryNode, ICheckable)
+    implements(IDirectoryNode, ICheckable, IDeepCheckable)
     filenode_class = MutableFileNode
 
     def __init__(self, client):
index 4f55819ac31b569e06731b83cf04b0b758bb651b..810e5e3f0c3e08545a422adf6805999581fb9f1a 100644 (file)
@@ -5,8 +5,6 @@ from allmydata.interfaces import IFileNode, IFileURI, IURI, ICheckable
 from allmydata import uri
 from allmydata.immutable.checker import SimpleCHKFileChecker, \
      SimpleCHKFileVerifier
-from allmydata.checker_results import DeepCheckResults, \
-     DeepCheckAndRepairResults
 
 class FileNode:
     implements(IFileNode, ICheckable)
@@ -75,24 +73,6 @@ class FileNode:
         d.addCallback(_done)
         return d
 
-    def deep_check(self, verify=False):
-        d = self.check(verify)
-        def _done(r):
-            dr = DeepCheckResults(self.get_verifier().storage_index)
-            dr.add_check(r, [])
-            return dr
-        d.addCallback(_done)
-        return d
-
-    def deep_check_and_repair(self, verify=False):
-        d = self.check_and_repair(verify)
-        def _done(r):
-            dr = DeepCheckAndRepairResults(self.get_verifier().storage_index)
-            dr.add_check_and_repair(r, [])
-            return dr
-        d.addCallback(_done)
-        return d
-
     def download(self, target):
         downloader = self._client.getServiceNamed("downloader")
         return downloader.download(self.uri, target)
@@ -150,14 +130,6 @@ class LiteralFileNode:
     def check_and_repair(self, verify=False):
         return defer.succeed(None)
 
-    def deep_check(self, verify=False):
-        dr = DeepCheckResults(None)
-        return defer.succeed(dr)
-
-    def deep_check_and_repair(self, verify=False):
-        dr = DeepCheckAndRepairResults(None)
-        return defer.succeed(dr)
-
     def download(self, target):
         # note that this does not update the stats_provider
         data = IURI(self.uri).data
index 44065ff01d5e5d9665e6300d656218df3a46a1a3..c68ae11a0455856dbcd37d8e74c23695c94f945d 100644 (file)
@@ -1485,11 +1485,11 @@ class ICheckable(Interface):
         attempted, 'post' will be another ICheckerResults instance with the
         state of the object after repair."""
 
+class IDeepCheckable(Interface):
     def deep_check(verify=False):
         """Check upon the health of me and everything I can reach.
 
-        This is a recursive form of check(), useable on dirnodes. (it can be
-        called safely on filenodes too, but only checks the one object).
+        This is a recursive form of check(), useable only on dirnodes.
 
         I return a Deferred that fires with an IDeepCheckResults object.
         """
@@ -1498,9 +1498,8 @@ class ICheckable(Interface):
         """Check upon the health of me and everything I can reach. Repair
         anything that isn't healthy.
 
-        This is a recursive form of check_and_repair(), useable on dirnodes.
-        (it can be called safely on filenodes too, but only checks/repairs
-        the one object).
+        This is a recursive form of check_and_repair(), useable only on
+        dirnodes.
 
         I return a Deferred that fires with an IDeepCheckAndRepairResults
         object.
index 3ad4fd56e655bc569a1bb6737c284ae269fc066f..b70e0c15d2ddb096e5ade930968f01e4c7bcb8b4 100644 (file)
@@ -12,8 +12,6 @@ from allmydata.util import hashutil
 from allmydata.util.assertutil import precondition
 from allmydata.uri import WriteableSSKFileURI
 from allmydata.immutable.encode import NotEnoughSharesError
-from allmydata.checker_results import DeepCheckResults, \
-     DeepCheckAndRepairResults
 from pycryptopp.publickey import rsa
 from pycryptopp.cipher.aes import AES
 
@@ -253,25 +251,6 @@ class MutableFileNode:
         checker = self.check_and_repairer_class(self)
         return checker.check(verify)
 
-    def deep_check(self, verify=False):
-        # deep-check on a filenode only gets one result
-        d = self.check(verify)
-        def _done(r):
-            dr = DeepCheckResults(self.get_storage_index())
-            dr.add_check(r, [])
-            return dr
-        d.addCallback(_done)
-        return d
-
-    def deep_check_and_repair(self, verify=False):
-        d = self.check_and_repair(verify)
-        def _done(r):
-            dr = DeepCheckAndRepairResults(self.get_storage_index())
-            dr.add_check_and_repair(r, [])
-            return dr
-        d.addCallback(_done)
-        return d
-
     #################################
     # IRepairable
 
index 8ccdbd7146593eebc31fe9f59155831457023ae4..0f759194eac1e6d9066204316bfe0d1f9e5d7563 100644 (file)
@@ -134,19 +134,6 @@ class Checker(unittest.TestCase):
 
         # TODO: check-and-repair
 
-        d.addCallback(lambda res: fn1.deep_check())
-        def _check_deepcheck_results(dcr):
-            c = dcr.get_counters()
-            self.failUnlessEqual(c["count-objects-checked"], 1)
-            self.failUnlessEqual(c["count-objects-healthy"], 1)
-            self.failUnlessEqual(c["count-objects-unhealthy"], 0)
-            self.failUnlessEqual(c["count-corrupt-shares"], 0)
-            self.failIf(dcr.get_corrupt_shares())
-        d.addCallback(_check_deepcheck_results)
-
-        d.addCallback(lambda res: fn1.deep_check(verify=True))
-        d.addCallback(_check_deepcheck_results)
-
         return d
 
     def test_literal_filenode(self):
@@ -163,19 +150,6 @@ class Checker(unittest.TestCase):
         d.addCallback(lambda res: fn1.check(verify=True))
         d.addCallback(_check_checker_results)
 
-        d.addCallback(lambda res: fn1.deep_check())
-        def _check_deepcheck_results(dcr):
-            c = dcr.get_counters()
-            self.failUnlessEqual(c["count-objects-checked"], 0)
-            self.failUnlessEqual(c["count-objects-healthy"], 0)
-            self.failUnlessEqual(c["count-objects-unhealthy"], 0)
-            self.failUnlessEqual(c["count-corrupt-shares"], 0)
-            self.failIf(dcr.get_corrupt_shares())
-        d.addCallback(_check_deepcheck_results)
-
-        d.addCallback(lambda res: fn1.deep_check(verify=True))
-        d.addCallback(_check_deepcheck_results)
-
         return d
 
     def test_mutable_filenode(self):
@@ -199,19 +173,6 @@ class Checker(unittest.TestCase):
         d.addCallback(lambda res: n.check(verify=True))
         d.addCallback(_check_checker_results)
 
-        d.addCallback(lambda res: n.deep_check())
-        def _check_deepcheck_results(dcr):
-            c = dcr.get_counters()
-            self.failUnlessEqual(c["count-objects-checked"], 1)
-            self.failUnlessEqual(c["count-objects-healthy"], 1)
-            self.failUnlessEqual(c["count-objects-unhealthy"], 0)
-            self.failUnlessEqual(c["count-corrupt-shares"], 0)
-            self.failIf(dcr.get_corrupt_shares())
-        d.addCallback(_check_deepcheck_results)
-
-        d.addCallback(lambda res: n.deep_check(verify=True))
-        d.addCallback(_check_deepcheck_results)
-
         return d
 
 class FakeMutableChecker:
index 2361869797b5f2b1aa137dc5e424132a622e8d01..6f557a05c881e8899b8c47454b93d5de7ad2383e 100644 (file)
@@ -2162,46 +2162,15 @@ class DeepCheck(SystemTestMixin, unittest.TestCase):
         d.addCallback(self.failUnlessEqual, None, "small")
 
 
-        # now deep-check on everything. It should be safe to use deep-check
-        # on anything, even a regular file.
+        # now deep-check the root, with various verify= and repair= options
         d.addCallback(lambda ign: self.root.deep_check())
         d.addCallback(self.deep_check_is_healthy, 3, "root")
-        d.addCallback(lambda ign: self.mutable.deep_check())
-        d.addCallback(self.deep_check_is_healthy, 1, "mutable")
-        d.addCallback(lambda ign: self.large.deep_check())
-        d.addCallback(self.deep_check_is_healthy, 1, "large")
-        d.addCallback(lambda ign: self.small.deep_check())
-        d.addCallback(self.deep_check_is_healthy, 0, "small")
-
-        # deep-check verify=True
         d.addCallback(lambda ign: self.root.deep_check(verify=True))
         d.addCallback(self.deep_check_is_healthy, 3, "root")
-        d.addCallback(lambda ign: self.mutable.deep_check(verify=True))
-        d.addCallback(self.deep_check_is_healthy, 1, "mutable")
-        d.addCallback(lambda ign: self.large.deep_check(verify=True))
-        d.addCallback(self.deep_check_is_healthy, 1, "large")
-        d.addCallback(lambda ign: self.small.deep_check(verify=True))
-        d.addCallback(self.deep_check_is_healthy, 0, "small")
-
-        # deep-check-and-repair
         d.addCallback(lambda ign: self.root.deep_check_and_repair())
         d.addCallback(self.deep_check_and_repair_is_healthy, 3, "root")
-        d.addCallback(lambda ign: self.mutable.deep_check_and_repair())
-        d.addCallback(self.deep_check_and_repair_is_healthy, 1, "mutable")
-        d.addCallback(lambda ign: self.large.deep_check_and_repair())
-        d.addCallback(self.deep_check_and_repair_is_healthy, 1, "large")
-        d.addCallback(lambda ign: self.small.deep_check_and_repair())
-        d.addCallback(self.deep_check_and_repair_is_healthy, 0, "small")
-
-        # deep-check-and-repair, verify=True
         d.addCallback(lambda ign: self.root.deep_check_and_repair(verify=True))
         d.addCallback(self.deep_check_and_repair_is_healthy, 3, "root")
-        d.addCallback(lambda ign: self.mutable.deep_check_and_repair(verify=True))
-        d.addCallback(self.deep_check_and_repair_is_healthy, 1, "mutable")
-        d.addCallback(lambda ign: self.large.deep_check_and_repair(verify=True))
-        d.addCallback(self.deep_check_and_repair_is_healthy, 1, "large")
-        d.addCallback(lambda ign: self.small.deep_check_and_repair(verify=True))
-        d.addCallback(self.deep_check_and_repair_is_healthy, 0, "small")
 
         return d
 
@@ -2361,8 +2330,7 @@ class DeepCheck(SystemTestMixin, unittest.TestCase):
                       self.web_json(self.small, t="check", repair="true", verify="true"))
         d.addCallback(self.json_check_lit, self.small, "small")
 
-        # now run a deep-check. When done through the web, this can only be
-        # run on a directory.
+        # now run a deep-check, with various verify= and repair= flags
         d.addCallback(lambda ign:
                       self.web_json(self.root, t="deep-check"))
         d.addCallback(self.json_full_deepcheck_is_healthy, self.root, "root")