from allmydata.util.abbreviate import parse_abbreviated_size
from allmydata.util.time_format import parse_duration, parse_date
from allmydata.uri import LiteralFileURI, UnknownURI
-from allmydata.dirnode import NewDirectoryNode
+from allmydata.dirnode import DirectoryNode
from allmydata.mutable.filenode import MutableFileNode
from allmydata.unknown import UnknownNode
from allmydata.stats import StatsProvider
from allmydata.history import History
-from allmydata.interfaces import IURI, INewDirectoryURI, IStatsProducer, \
- IReadonlyNewDirectoryURI, IFileURI, IMutableFileURI, RIStubClient, \
+from allmydata.interfaces import IURI, IDirectoryURI, IStatsProducer, \
+ IReadonlyDirectoryURI, IFileURI, IMutableFileURI, RIStubClient, \
UnhandledCapTypeError
KiB=1024
return UnknownNode(writecap, readcap)
u_s = u.to_string()
if u_s not in self._node_cache:
- if IReadonlyNewDirectoryURI.providedBy(u):
- # new-style read-only dirnodes
- node = NewDirectoryNode(self).init_from_uri(u)
- elif INewDirectoryURI.providedBy(u):
- # new-style dirnodes
- node = NewDirectoryNode(self).init_from_uri(u)
+ if IReadonlyDirectoryURI.providedBy(u):
+ # read-only dirnodes
+ node = DirectoryNode(self).init_from_uri(u)
+ elif IDirectoryURI.providedBy(u):
+ # dirnodes
+ node = DirectoryNode(self).init_from_uri(u)
elif IFileURI.providedBy(u):
if isinstance(u, LiteralFileURI):
node = LiteralFileNode(u, self) # LIT
def create_empty_dirnode(self):
d = self.create_mutable_file()
- d.addCallback(NewDirectoryNode.create_with_mutablefile, self)
+ d.addCallback(DirectoryNode.create_with_mutablefile, self)
return d
def create_mutable_file(self, contents="", keysize=None):
from allmydata.util import hashutil, mathutil, base32, log
from allmydata.util.assertutil import _assert, precondition
from allmydata.util.netstring import netstring, split_netstring
-from allmydata.uri import NewDirectoryURI, LiteralFileURI, from_string
+from allmydata.uri import DirectoryURI, LiteralFileURI, from_string
from pycryptopp.cipher.aes import AES
class CachingDict(dict):
new_contents = self.node._pack_contents(children)
return new_contents
-class NewDirectoryNode:
+class DirectoryNode:
implements(IDirectoryNode, ICheckable, IDeepCheckable)
filenode_class = MutableFileNode
d.addCallback(self._filenode_created)
return d
def _filenode_created(self, res):
- self._uri = NewDirectoryURI(IMutableFileURI(self._node.get_uri()))
+ self._uri = DirectoryURI(IMutableFileURI(self._node.get_uri()))
return self
def get_size(self):
class IMutableFileURI(Interface):
"""I am a URI which represents a mutable filenode."""
-class INewDirectoryURI(Interface):
+class IDirectoryURI(Interface):
pass
-class IReadonlyNewDirectoryURI(Interface):
+class IReadonlyDirectoryURI(Interface):
pass
class CannotPackUnknownNodeError(Exception):
IFileNode or IMutableFileNode -providing instances, like
FileNode, LiteralFileNode, or MutableFileNode.
Directory-specifying URIs will result in
- IDirectoryNode-providing instances, like NewDirectoryNode.
+ IDirectoryNode-providing instances, like DirectoryNode.
"""
class IClientStatus(Interface):
print >>out, " storage index:", si_b2a(u.storage_index)
print >>out, " fingerprint:", base32.b2a(u.fingerprint)
- elif isinstance(u, uri.NewDirectoryURI):
+ elif isinstance(u, uri.DirectoryURI):
if show_header:
print >>out, "Directory Writeable URI:"
dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)
- elif isinstance(u, uri.ReadonlyNewDirectoryURI):
+ elif isinstance(u, uri.ReadonlyDirectoryURI):
if show_header:
print >>out, "Directory Read-only URI:"
dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)
- elif isinstance(u, uri.NewDirectoryURIVerifier):
+ elif isinstance(u, uri.DirectoryURIVerifier):
if show_header:
print >>out, "Directory Verifier URI:"
dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)
mut_filenode.MutableFileNode.__init__(self, client)
self._uri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))
-class FakeDirectoryNode(dirnode.NewDirectoryNode):
+class FakeDirectoryNode(dirnode.DirectoryNode):
def __init__(self, client):
- dirnode.NewDirectoryNode.__init__(self, client)
+ dirnode.DirectoryNode.__init__(self, client)
mutfileuri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))
- myuri = uri.NewDirectoryURI(mutfileuri)
+ myuri = uri.DirectoryURI(mutfileuri)
self.init_from_uri(myuri)
children = [] # tuples of (k, v) (suitable for passing to dict())
packstr = None
fakeclient = FakeClient()
-testdirnode = dirnode.NewDirectoryNode(fakeclient)
-testdirnode.init_from_uri(uri.NewDirectoryURI(uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))))
+testdirnode = dirnode.DirectoryNode(fakeclient)
+testdirnode.init_from_uri(uri.DirectoryURI(uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))))
def random_unicode(l):
while True:
return uri.SSKVerifierURI(storage_index=os.urandom(16),
fingerprint=os.urandom(32))
-class FakeDirectoryNode(dirnode.NewDirectoryNode):
+class FakeDirectoryNode(dirnode.DirectoryNode):
"""This offers IDirectoryNode, but uses a FakeMutableFileNode for the
backing store, so it doesn't go to the grid. The child data is still
encrypted and serialized, so this isn't useful for tests that want to
open("cli/test_options/node.url","w").write("http://localhost:8080/\n")
filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16,
fingerprint="\x00"*32)
- private_uri = uri.NewDirectoryURI(filenode_uri).to_string()
+ private_uri = uri.DirectoryURI(filenode_uri).to_string()
open("cli/test_options/private/root_dir.cap", "w").write(private_uri + "\n")
o = cli.ListOptions()
o.parseOptions(["--node-directory", "cli/test_options"])
o = cli.ListOptions()
other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16,
fingerprint="\x11"*32)
- other_uri = uri.NewDirectoryURI(other_filenode_uri).to_string()
+ other_uri = uri.DirectoryURI(other_filenode_uri).to_string()
o.parseOptions(["--node-directory", "cli/test_options",
"--dir-cap", other_uri])
self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
writekey = "\x01" * 16
fingerprint = "\xfe" * 32
u1 = uri.WriteableSSKFileURI(writekey, fingerprint)
- u = uri.NewDirectoryURI(u1)
+ u = uri.DirectoryURI(u1)
output = self._dump_cap(u.to_string())
self.failUnless("Directory Writeable URI:" in output, output)
from allmydata.client import Client
from allmydata.immutable import upload
from allmydata.interfaces import IURI, IClient, IMutableFileNode, \
- INewDirectoryURI, IReadonlyNewDirectoryURI, IFileNode, \
+ IDirectoryURI, IReadonlyDirectoryURI, IFileNode, \
ExistingChildError, NoSuchChildError, \
IDeepCheckResults, IDeepCheckAndRepairResults, CannotPackUnknownNodeError
from allmydata.mutable.filenode import MutableFileNode
if not u:
u = readcap
u = IURI(u)
- if (INewDirectoryURI.providedBy(u)
- or IReadonlyNewDirectoryURI.providedBy(u)):
+ if (IDirectoryURI.providedBy(u)
+ or IReadonlyDirectoryURI.providedBy(u)):
return FakeDirectoryNode(self).init_from_uri(u)
return Marker(u.to_string())
return res
d.addCallback(_ucwe)
return d
-class UCWEingNewDirectoryNode(dirnode.NewDirectoryNode):
+class UCWEingDirectoryNode(dirnode.DirectoryNode):
filenode_class = UCWEingMutableFileNode
return dn.add_file(u"file", small)
d.addCallback(_created_dir)
def _do_delete(ignored):
- n = UCWEingNewDirectoryNode(c0).init_from_uri(self.root_uri)
+ n = UCWEingDirectoryNode(c0).init_from_uri(self.root_uri)
assert n._node.please_ucwe_after_next_upload == False
n._node.please_ucwe_after_next_upload = True
# This should succeed, not raise an exception
class Constraint(unittest.TestCase):
def test_constraint(self):
good="http://127.0.0.1:3456/uri/URI%3ADIR2%3Agh3l5rbvnv2333mrfvalmjfr4i%3Alz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma/"
- uri.NewDirectoryURI.init_from_human_encoding(good)
- self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_string, good)
+ uri.DirectoryURI.init_from_human_encoding(good)
+ self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_string, good)
bad = good + '==='
- self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_human_encoding, bad)
- self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_string, bad)
+ self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_human_encoding, bad)
+ self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_string, bad)
fileURI = 'URI:CHK:gh3l5rbvnv2333mrfvalmjfr4i:lz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma:3:10:345834'
uri.CHKFileURI.init_from_string(fileURI)
fingerprint = "\x02" * 32
n = uri.WriteableSSKFileURI(writekey, fingerprint)
- u1 = uri.NewDirectoryURI(n)
+ u1 = uri.DirectoryURI(n)
self.failIf(u1.is_readonly())
self.failUnless(u1.is_mutable())
self.failUnless(IURI.providedBy(u1))
self.failIf(IFileURI.providedBy(u1))
self.failUnless(IDirnodeURI.providedBy(u1))
- self.failUnless("NewDirectoryURI" in str(u1))
+ self.failUnless("DirectoryURI" in str(u1))
u1_filenode = u1.get_filenode_uri()
self.failUnless(u1_filenode.is_mutable())
self.failIf(u1_filenode.is_readonly())
u3a = uri.from_string(u3.to_string())
self.failUnlessIdentical(u3a, u3a.get_readonly())
- u4 = uri.ReadonlyNewDirectoryURI(u2._filenode_uri.get_readonly())
+ u4 = uri.ReadonlyDirectoryURI(u2._filenode_uri.get_readonly())
self.failUnlessEqual(u4.to_string(), u3.to_string())
self.failUnless(u4.is_readonly())
self.failUnless(u4.is_mutable())
verifiers = [u1.get_verify_cap(), u2.get_verify_cap(),
u3.get_verify_cap(), u4.get_verify_cap(),
IVerifierURI(u1.get_verify_cap().to_string()),
- uri.NewDirectoryURIVerifier(n.get_verify_cap()),
- uri.NewDirectoryURIVerifier(n.get_verify_cap().to_string()),
+ uri.DirectoryURIVerifier(n.get_verify_cap()),
+ uri.DirectoryURIVerifier(n.get_verify_cap().to_string()),
]
for v in verifiers:
self.failUnless(IVerifierURI.providedBy(v))
from allmydata.util.assertutil import precondition
from allmydata.test.common import FakeDirectoryNode, FakeCHKFileNode, \
FakeMutableFileNode, create_chk_filenode, WebErrorMixin, ShouldFailMixin
-from allmydata.interfaces import IURI, INewDirectoryURI, \
- IReadonlyNewDirectoryURI, IFileURI, IMutableFileURI, IMutableFileNode, \
- UnhandledCapTypeError
+from allmydata.interfaces import IURI, IDirectoryURI, IReadonlyDirectoryURI, \
+ IFileURI, IMutableFileURI, IMutableFileNode, UnhandledCapTypeError
from allmydata.mutable import servermap, publish, retrieve
import common_util as testutil
from allmydata.test.no_network import GridTestMixin
auri = readcap
precondition(isinstance(auri, str), auri)
u = uri.from_string(auri)
- if (INewDirectoryURI.providedBy(u)
- or IReadonlyNewDirectoryURI.providedBy(u)):
+ if (IDirectoryURI.providedBy(u) or IReadonlyDirectoryURI.providedBy(u)):
return FakeDirectoryNode(self).init_from_uri(u)
if IFileURI.providedBy(u):
return FakeCHKFileNode(u, self)
def test_POST_mkdir_no_parentdir_noredirect(self):
d = self.POST("/uri?t=mkdir")
def _after_mkdir(res):
- uri.NewDirectoryURI.init_from_string(res)
+ uri.DirectoryURI.init_from_string(res)
d.addCallback(_after_mkdir)
return d
from allmydata.storage.server import si_a2b, si_b2a
from allmydata.util import base32, hashutil
from allmydata.interfaces import IURI, IDirnodeURI, IFileURI, IImmutableFileURI, \
- IVerifierURI, IMutableFileURI, INewDirectoryURI, IReadonlyNewDirectoryURI
+ IVerifierURI, IMutableFileURI, IDirectoryURI, IReadonlyDirectoryURI
class BadURIError(Exception):
pass
return 'URI:SSK-Verifier:%s:%s' % (si_b2a(self.storage_index),
base32.b2a(self.fingerprint))
-class _NewDirectoryBaseURI(_BaseURI):
+class _DirectoryBaseURI(_BaseURI):
implements(IURI, IDirnodeURI)
def __init__(self, filenode_uri=None):
self._filenode_uri = filenode_uri
return True
def get_verify_cap(self):
- return NewDirectoryURIVerifier(self._filenode_uri.get_verify_cap())
+ return DirectoryURIVerifier(self._filenode_uri.get_verify_cap())
def get_storage_index(self):
return self._filenode_uri.get_storage_index()
-class NewDirectoryURI(_NewDirectoryBaseURI):
- implements(INewDirectoryURI)
+class DirectoryURI(_DirectoryBaseURI):
+ implements(IDirectoryURI)
BASE_STRING='URI:DIR2:'
BASE_STRING_RE=re.compile('^'+BASE_STRING)
def __init__(self, filenode_uri=None):
if filenode_uri:
assert not filenode_uri.is_readonly()
- _NewDirectoryBaseURI.__init__(self, filenode_uri)
+ _DirectoryBaseURI.__init__(self, filenode_uri)
def is_readonly(self):
return False
def get_readonly(self):
- return ReadonlyNewDirectoryURI(self._filenode_uri.get_readonly())
+ return ReadonlyDirectoryURI(self._filenode_uri.get_readonly())
-class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI):
- implements(IReadonlyNewDirectoryURI)
+class ReadonlyDirectoryURI(_DirectoryBaseURI):
+ implements(IReadonlyDirectoryURI)
BASE_STRING='URI:DIR2-RO:'
BASE_STRING_RE=re.compile('^'+BASE_STRING)
def __init__(self, filenode_uri=None):
if filenode_uri:
assert filenode_uri.is_readonly()
- _NewDirectoryBaseURI.__init__(self, filenode_uri)
+ _DirectoryBaseURI.__init__(self, filenode_uri)
def is_readonly(self):
return True
def get_readonly(self):
return self
-class NewDirectoryURIVerifier(_NewDirectoryBaseURI):
+class DirectoryURIVerifier(_DirectoryBaseURI):
implements(IVerifierURI)
BASE_STRING='URI:DIR2-Verifier:'
elif s.startswith('URI:SSK-Verifier:'):
return SSKVerifierURI.init_from_string(s)
elif s.startswith('URI:DIR2:'):
- return NewDirectoryURI.init_from_string(s)
+ return DirectoryURI.init_from_string(s)
elif s.startswith('URI:DIR2-RO:'):
- return ReadonlyNewDirectoryURI.init_from_string(s)
+ return ReadonlyDirectoryURI.init_from_string(s)
elif s.startswith('URI:DIR2-Verifier:'):
- return NewDirectoryURIVerifier.init_from_string(s)
+ return DirectoryURIVerifier.init_from_string(s)
return UnknownURI(s)
registerAdapter(from_string, str, IURI)