self.cachefile = None
self.download_in_progress = False
# five states:
- # new FileNode, no downloads ever performed
- # new FileNode, leftover file (partial)
- # new FileNode, leftover file (whole)
+ # new ImmutableFileNode, no downloads ever performed
+ # new ImmutableFileNode, leftover file (partial)
+ # new ImmutableFileNode, leftover file (whole)
# download in progress, not yet complete
# download complete
pass
-class FileNode(_ImmutableFileNodeBase, log.PrefixingLogMixin):
+class ImmutableFileNode(_ImmutableFileNodeBase, log.PrefixingLogMixin):
def __init__(self, filecap, storage_broker, secret_holder,
downloader, history, cachedirectorymanager):
assert isinstance(filecap, CHKFileURI)
def add_file(name, uploadable, metadata=None, overwrite=True):
"""I upload a file (using the given IUploadable), then attach the
- resulting FileNode to the directory at the given name. I set metadata
- the same way as set_uri and set_node. The child name must be a
- unicode string.
+ resulting ImmutableFileNode to the directory at the given name. I set
+ metadata the same way as set_uri and set_node. The child name must be
+ a unicode string.
I return a Deferred that fires (with the IFileNode of the uploaded
file) when the operation completes."""
@return: an instance that provides IFilesystemNode (or more usefully
one of its subclasses). File-specifying URIs will result in
IFileNode or IMutableFileNode -providing instances, like
- FileNode, LiteralFileNode, or MutableFileNode.
+ ImmutableFileNode, LiteralFileNode, or MutableFileNode.
Directory-specifying URIs will result in
IDirectoryNode-providing instances, like DirectoryNode.
"""
from zope.interface import implements
from allmydata.util.assertutil import precondition
from allmydata.interfaces import INodeMaker, NotDeepImmutableError
-from allmydata.immutable.filenode import FileNode, LiteralFileNode
+from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode
from allmydata.immutable.upload import Data
from allmydata.mutable.filenode import MutableFileNode
from allmydata.dirnode import DirectoryNode, pack_children
def _create_lit(self, cap):
return LiteralFileNode(cap)
def _create_immutable(self, cap):
- return FileNode(cap, self.storage_broker, self.secret_holder,
- self.downloader, self.history,
- self.download_cache_dirman)
+ return ImmutableFileNode(cap, self.storage_broker, self.secret_holder,
+ self.downloader, self.history,
+ self.download_cache_dirman)
def _create_mutable(self, cap):
n = MutableFileNode(self.storage_broker, self.secret_holder,
self.default_encoding_parameters,
from pyutil import benchutil, randutil # http://allmydata.org/trac/pyutil
+from zope.interface import implements
from allmydata import dirnode, uri
-from allmydata.mutable import filenode as mut_filenode
-from allmydata.immutable import filenode as immut_filenode
+from allmydata.interfaces import IFileNode
+from allmydata.mutable.filenode import MutableFileNode
+from allmydata.immutable.filenode import ImmutableFileNode
children = [] # tuples of (k, v) (suitable for passing to dict())
packstr = None
class ContainerNode:
+ implements(IFileNode)
# dirnodes sit on top of a "container" filenode, from which it extracts a
# writekey
def __init__(self):
self._cap = uri.WriteableSSKFileURI(self._writekey, self._fingerprint)
def get_writekey(self):
return self._writekey
+ def get_cap(self):
+ return self._cap
def get_uri(self):
return self._cap.to_string()
def is_readonly(self):
random.randrange(1, 5),
random.randrange(6, 15),
random.randrange(99, 1000000000000))
- return immut_filenode.FileNode(cap, None, None, None, None, None)
+ return ImmutableFileNode(cap, None, None, None, None, None)
elif coin == 1:
cap = uri.WriteableSSKFileURI(randutil.insecurerandstr(16),
randutil.insecurerandstr(32))
- n = mut_filenode.MutableFileNode(None, None, encoding_parameters, None)
+ n = MutableFileNode(None, None, encoding_parameters, None)
return n.init_from_cap(cap)
else:
assert coin == 2
cap = uri.WriteableSSKFileURI(randutil.insecurerandstr(16),
randutil.insecurerandstr(32))
- n = mut_filenode.MutableFileNode(None, None, encoding_parameters, None)
+ n = MutableFileNode(None, None, encoding_parameters, None)
n.init_from_cap(cap)
return dirnode.DirectoryNode(n, nodemaker, uploader=None)
from twisted.trial import unittest
from allmydata import uri, client
from allmydata.monitor import Monitor
-from allmydata.immutable import filenode, download
+from allmydata.immutable import download
+from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode
from allmydata.mutable.filenode import MutableFileNode
from allmydata.util import hashutil, cachedir
from allmydata.test.common import download_to_data
size=1000)
c = FakeClient()
cf = cachedir.CacheFile("none")
- fn1 = filenode.FileNode(u, None, None, None, None, cf)
- fn2 = filenode.FileNode(u, None, None, None, None, cf)
+ fn1 = ImmutableFileNode(u, None, None, None, None, cf)
+ fn2 = ImmutableFileNode(u, None, None, None, None, cf)
self.failUnlessEqual(fn1, fn2)
self.failIfEqual(fn1, "I am not a filenode")
self.failIfEqual(fn1, NotANode())
DATA = "I am a short file."
u = uri.LiteralFileURI(data=DATA)
c = None
- fn1 = filenode.LiteralFileNode(u)
- fn2 = filenode.LiteralFileNode(u)
+ fn1 = LiteralFileNode(u)
+ fn2 = LiteralFileNode(u)
self.failUnlessEqual(fn1, fn2)
self.failIfEqual(fn1, "I am not a filenode")
self.failIfEqual(fn1, NotANode())
def test_literal_filenode(self):
DATA = "I am a short file."
u = uri.LiteralFileURI(data=DATA)
- fn1 = filenode.LiteralFileNode(u)
+ fn1 = LiteralFileNode(u)
d = fn1.check(Monitor())
def _check_checker_results(cr):
from allmydata import uri
from allmydata.storage.mutable import MutableShareFile
from allmydata.storage.server import si_a2b
-from allmydata.immutable import download, filenode, offloaded, upload
+from allmydata.immutable import download, offloaded, upload
+from allmydata.immutable.filenode import ImmutableFileNode, LiteralFileNode
from allmydata.util import idlib, mathutil
from allmydata.util import log, base32
from allmydata.scripts import runner
d.addCallback(lambda res: self._personal_node.get(u"big file"))
def _got_chk_filenode(n):
- self.failUnless(isinstance(n, filenode.FileNode))
+ self.failUnless(isinstance(n, ImmutableFileNode))
d = n.check(Monitor())
def _check_filenode_results(r):
self.failUnless(r.is_healthy())
d.addCallback(lambda res: self._personal_node.get(u"sekrit data"))
def _got_lit_filenode(n):
- self.failUnless(isinstance(n, filenode.LiteralFileNode))
+ self.failUnless(isinstance(n, LiteralFileNode))
d = n.check(Monitor())
def _check_lit_filenode_results(r):
self.failUnlessEqual(r, None)