From: Brian Warner Date: Wed, 5 Dec 2007 00:00:58 +0000 (-0700) Subject: remove most (maybe all?) traces of old Dirnode class. Yay for negative code days. X-Git-Url: https://git.rkrishnan.org/listings/provisioning?a=commitdiff_plain;h=cf2bd038137021174a679ee03c8e8b88ff4bb2da;p=tahoe-lafs%2Ftahoe-lafs.git remove most (maybe all?) traces of old Dirnode class. Yay for negative code days. --- diff --git a/src/allmydata/checker.py b/src/allmydata/checker.py index af11ecc3..fdb8d312 100644 --- a/src/allmydata/checker.py +++ b/src/allmydata/checker.py @@ -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. diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 4d78fb10..71550fa9 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -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/") diff --git a/src/allmydata/test/test_uri.py b/src/allmydata/test/test_uri.py index 77e11920..c8b4cfbb 100644 --- a/src/allmydata/test/test_uri.py +++ b/src/allmydata/test/test_uri.py @@ -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" diff --git a/src/allmydata/uri.py b/src/allmydata/uri.py index 839a7f10..1aea18e2 100644 --- a/src/allmydata/uri.py +++ b/src/allmydata/uri.py @@ -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:"):