]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
remove most (maybe all?) traces of old Dirnode class. Yay for negative code days.
authorBrian Warner <warner@allmydata.com>
Wed, 5 Dec 2007 00:00:58 +0000 (17:00 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 5 Dec 2007 00:00:58 +0000 (17:00 -0700)
src/allmydata/checker.py
src/allmydata/test/test_cli.py
src/allmydata/test/test_uri.py
src/allmydata/uri.py

index af11ecc30956a11ff82a2ff111c46f56107ec89c..fdb8d3121f5fd7208d0672f502a9b4f33b8b38bb 100644 (file)
@@ -70,30 +70,6 @@ class SimpleCHKFileChecker:
         return (u.needed_shares, u.total_shares, len(self.found_shares),
                 self.sharemap)
 
-class SimpleDirnodeChecker:
-
-    def __init__(self, tub):
-        self.tub = tub
-
-    def check(self, node):
-        si = node.storage_index
-        d = self.tub.getReference(node.furl)
-        d.addCallback(self._get_dirnode, node.storage_index)
-        d.addCallbacks(self._success, self._failed)
-        return d
-
-    def _get_dirnode(self, rref, storage_index):
-        d = rref.callRemote("list", storage_index)
-        return d
-
-    def _success(self, res):
-        return True
-    def _failed(self, f):
-        if f.check(IndexError):
-            return False
-        log.err(f)
-        return False
-
 class VerifyingOutput:
     def __init__(self, total_length):
         self._crypttext_hasher = hashutil.crypttext_hasher()
@@ -235,10 +211,6 @@ class Checker(service.MultiService):
             peer_getter = self.parent.get_permuted_peers
             c = SimpleCHKFileChecker(peer_getter, uri_to_check)
             d = c.check()
-        elif isinstance(uri_to_check, uri.DirnodeVerifierURI):
-            tub = self.parent.tub
-            c = SimpleDirnodeChecker(tub)
-            d = c.check(uri_to_check)
         else:
             return defer.succeed(True)  # TODO I don't know how to check, but I'm pretending to succeed.
 
@@ -257,11 +229,6 @@ class Checker(service.MultiService):
         elif isinstance(uri_to_verify, uri.CHKFileVerifierURI):
             v = SimpleCHKFileVerifier(self.parent, uri_to_verify)
             return v.start()
-        elif isinstance(uri_to_verify, uri.DirnodeVerifierURI):
-            # for dirnodes, checking and verifying are currently equivalent
-            tub = self.parent.tub
-            c = SimpleDirnodeChecker(tub)
-            return c.check(uri_to_verify)
         else:
             return defer.succeed(True)  # TODO I don't know how to verify, but I'm pretending to succeed.
 
index 4d78fb10fb27ee835e02cb441737fc5a0e02b82f..71550fa9e35cbc95b5e734a742f4da655c084d91 100644 (file)
@@ -16,7 +16,10 @@ class CLI(unittest.TestCase):
         fileutil.rm_dir("cli/test_options")
         fileutil.make_dirs("cli/test_options")
         open("cli/test_options/node.url","w").write("http://localhost:8080/\n")
-        private_uri = uri.DirnodeURI("furl", "key").to_string()
+        #private_uri = uri.DirnodeURI("furl", "key").to_string()
+        filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16,
+                                               fingerprint="\x00"*32)
+        private_uri = uri.NewDirectoryURI(filenode_uri).to_string()
         open("cli/test_options/my_private_dir.uri", "w").write(private_uri + "\n")
         o = cli.ListOptions()
         o.parseOptions(["--node-directory", "cli/test_options"])
@@ -44,7 +47,9 @@ class CLI(unittest.TestCase):
         self.failUnlessEqual(o['vdrive_pathname'], "")
 
         o = cli.ListOptions()
-        other_uri = uri.DirnodeURI("furl", "otherkey").to_string()
+        other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16,
+                                                     fingerprint="\x11"*32)
+        other_uri = uri.NewDirectoryURI(other_filenode_uri).to_string()
         o.parseOptions(["--node-directory", "cli/test_options",
                         "--root-uri", other_uri])
         self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
index 77e11920cb8f9bffce96de5f9ab6884832b5572c..c8b4cfbb89215b14bdcc110e16e0ece4961200ce 100644 (file)
@@ -128,48 +128,6 @@ class Extension(unittest.TestCase):
 
         readable = uri.unpack_extension_readable(ext)
 
-class Dirnode(unittest.TestCase):
-    def test_pack(self):
-        furl = "pb://stuff@morestuff:stuff/andstuff"
-        writekey = "\x01" * 16
-
-        u = uri.DirnodeURI(furl, writekey)
-        self.failUnlessEqual(u.furl, furl)
-        self.failUnlessEqual(u.writekey, writekey)
-        self.failIf(u.is_readonly())
-        self.failUnless(u.is_mutable())
-        self.failUnless(IURI.providedBy(u))
-        self.failIf(IFileURI.providedBy(u))
-        self.failUnless(IDirnodeURI.providedBy(u))
-
-        u2 = uri.from_string(u.to_string())
-        self.failUnlessEqual(u2.furl, furl)
-        self.failUnlessEqual(u2.writekey, writekey)
-        self.failIf(u2.is_readonly())
-        self.failUnless(u2.is_mutable())
-        self.failUnless(IURI.providedBy(u2))
-        self.failIf(IFileURI.providedBy(u2))
-        self.failUnless(IDirnodeURI.providedBy(u2))
-
-        u3 = u2.get_readonly()
-        readkey = hashutil.dir_read_key_hash(writekey)
-        self.failUnlessEqual(u3.furl, furl)
-        self.failUnlessEqual(u3.readkey, readkey)
-        self.failUnless(u3.is_readonly())
-        self.failUnless(u3.is_mutable())
-        self.failUnless(IURI.providedBy(u3))
-        self.failIf(IFileURI.providedBy(u3))
-        self.failUnless(IDirnodeURI.providedBy(u3))
-
-        u4 = uri.ReadOnlyDirnodeURI(furl, readkey)
-        self.failUnlessEqual(u4.furl, furl)
-        self.failUnlessEqual(u4.readkey, readkey)
-        self.failUnless(u4.is_readonly())
-        self.failUnless(u4.is_mutable())
-        self.failUnless(IURI.providedBy(u4))
-        self.failIf(IFileURI.providedBy(u4))
-        self.failUnless(IDirnodeURI.providedBy(u4))
-
 class Invalid(unittest.TestCase):
     def test_create_invalid(self):
         not_uri = "I am not a URI"
index 839a7f10518c042f7913800c8aee8a7aa18e8411..1aea18e27f69a6b05d1cf2054bbeb8f27d349a96 100644 (file)
@@ -384,115 +384,6 @@ class NewDirectoryURIVerifier(_BaseURI):
 
 
 
-class DirnodeURI(_BaseURI):
-    implements(IURI, IDirnodeURI)
-
-    def __init__(self, furl=None, writekey=None):
-        if furl is not None or writekey is not None:
-            assert furl is not None
-            assert writekey is not None
-            self.furl = furl
-            self.writekey = writekey
-            self._derive_values()
-
-    def init_from_string(self, uri):
-        # URI:DIR:furl:key
-        #  but note that the furl contains colons
-        prefix = "URI:DIR:"
-        assert uri.startswith(prefix)
-        uri = uri[len(prefix):]
-        colon = uri.rindex(":")
-        self.furl = uri[:colon]
-        self.writekey = idlib.a2b(uri[colon+1:])
-        self._derive_values()
-        return self
-
-    def _derive_values(self):
-        wk, we, rk, index = \
-            hashutil.generate_dirnode_keys_from_writekey(self.writekey)
-        self.write_enabler = we
-        self.readkey = rk
-        self.storage_index = index
-
-    def to_string(self):
-        return "URI:DIR:%s:%s" % (self.furl, idlib.b2a(self.writekey))
-
-    def is_readonly(self):
-        return False
-    def is_mutable(self):
-        return True
-    def get_readonly(self):
-        return ReadOnlyDirnodeURI(self.furl, self.readkey)
-    def get_verifier(self):
-        return DirnodeVerifierURI(self.furl, self.storage_index)
-
-class ReadOnlyDirnodeURI(_BaseURI):
-    implements(IURI, IDirnodeURI)
-
-    def __init__(self, furl=None, readkey=None):
-        if furl is not None or readkey is not None:
-            assert furl is not None
-            assert readkey is not None
-            self.furl = furl
-            self.readkey = readkey
-            self._derive_values()
-
-    def init_from_string(self, uri):
-        # URI:DIR-RO:furl:key
-        #  but note that the furl contains colons
-        prefix = "URI:DIR-RO:"
-        assert uri.startswith(prefix)
-        uri = uri[len(prefix):]
-        colon = uri.rindex(":")
-        self.furl = uri[:colon]
-        self.readkey = idlib.a2b(uri[colon+1:])
-        self._derive_values()
-        return self
-
-    def _derive_values(self):
-        wk, we, rk, index = \
-            hashutil.generate_dirnode_keys_from_readkey(self.readkey)
-        self.writekey = wk # None
-        self.write_enabler = we # None
-        self.storage_index = index
-
-    def to_string(self):
-        return "URI:DIR-RO:%s:%s" % (self.furl, idlib.b2a(self.readkey))
-
-    def is_readonly(self):
-        return True
-    def is_mutable(self):
-        return True
-    def get_readonly(self):
-        return self
-    def get_verifier(self):
-        return DirnodeVerifierURI(self.furl, self.storage_index)
-
-class DirnodeVerifierURI(_BaseURI):
-    implements(IVerifierURI)
-
-    def __init__(self, furl=None, storage_index=None):
-        if furl is not None or storage_index is not None:
-            assert furl is not None
-            assert storage_index is not None
-            self.furl = furl
-            self.storage_index = storage_index
-
-    def init_from_string(self, uri):
-        # URI:DIR-Verifier:furl:storageindex
-        #  but note that the furl contains colons
-        prefix = "URI:DIR-Verifier:"
-        assert uri.startswith(prefix)
-        uri = uri[len(prefix):]
-        colon = uri.rindex(":")
-        self.furl = uri[:colon]
-        self.storage_index = idlib.a2b(uri[colon+1:])
-        return self
-
-    def to_string(self):
-        return "URI:DIR-Verifier:%s:%s" % (self.furl,
-                                           idlib.b2a(self.storage_index))
-
 
 
 def from_string(s):
@@ -502,12 +393,6 @@ def from_string(s):
         return CHKFileVerifierURI().init_from_string(s)
     elif s.startswith("URI:LIT:"):
         return LiteralFileURI().init_from_string(s)
-    elif s.startswith("URI:DIR:"):
-        return DirnodeURI().init_from_string(s)
-    elif s.startswith("URI:DIR-RO:"):
-        return ReadOnlyDirnodeURI().init_from_string(s)
-    elif s.startswith("URI:DIR-Verifier:"):
-        return DirnodeVerifierURI().init_from_string(s)
     elif s.startswith("URI:SSK:"):
         return WriteableSSKFileURI().init_from_string(s)
     elif s.startswith("URI:SSK-RO:"):