else:
key = base32.b2a(u.storage_index)
cachefile = self.download_cache.get_file(key)
- node = FileNode(u, self, cachefile) # CHK
+ node = FileNode(u.to_string(), self, cachefile) # CHK
else:
assert IMutableFileURI.providedBy(u), u
node = MutableFileNode(self).init_from_uri(u)
self._all_download_statuses = weakref.WeakKeyDictionary()
self._recent_download_statuses = []
- def download(self, u, t):
+ def download(self, u, t, _log_msg_id=None):
assert self.parent
assert self.running
u = IFileURI(u)
return d
# utility functions
- def download_to_data(self, uri):
- return self.download(uri, Data())
- def download_to_filename(self, uri, filename):
- return self.download(uri, FileName(filename))
- def download_to_filehandle(self, uri, filehandle):
- return self.download(uri, FileHandle(filehandle))
+ def download_to_data(self, uri, _log_msg_id=None):
+ return self.download(uri, Data(), _log_msg_id=_log_msg_id)
+ def download_to_filename(self, uri, filename, _log_msg_id=None):
+ return self.download(uri, FileName(filename), _log_msg_id=_log_msg_id)
+ def download_to_filehandle(self, uri, filehandle, _log_msg_id=None):
+ return self.download(uri, FileHandle(filehandle), _log_msg_id=_log_msg_id)
def _add_download(self, downloader):
self._all_downloads[downloader] = None
from allmydata.interfaces import IFileNode, IFileURI, ICheckable, \
IDownloadTarget
from allmydata.util import log, base32
+from allmydata import uri as urimodule
from allmydata.immutable.checker import Checker
from allmydata.check_results import CheckAndRepairResults
from allmydata.immutable.repairer import Repairer
-class FileNode(_ImmutableFileNodeBase):
+class FileNode(_ImmutableFileNodeBase, log.PrefixingLogMixin):
def __init__(self, uri, client, cachefile):
_ImmutableFileNodeBase.__init__(self, uri, client)
self.download_cache = DownloadCache(self, cachefile)
+ prefix = urimodule.from_string(uri).get_verify_cap().to_string()
+ log.PrefixingLogMixin.__init__(self, "allmydata.immutable.filenode", prefix=prefix)
+ self.log("starting", level=log.OPERATIONAL)
def get_uri(self):
return self.u.to_string()
if offset == 0 and size == self.get_size():
# don't use the cache, just do a normal streaming download
- log.msg(format=("immutable filenode read [%(si)s]: " +
- "doing normal full download"),
- si=base32.b2a(self.u.storage_index),
- umid="VRSBwg", level=log.OPERATIONAL)
+ self.log("doing normal full download", umid="VRSBwg", level=log.OPERATIONAL)
return self.download(download.ConsumerAdapter(consumer))
d = self.download_cache.when_range_available(offset, size)
def download(self, target):
downloader = self._client.getServiceNamed("downloader")
- return downloader.download(self.get_uri(), target)
+ return downloader.download(self.get_uri(), target, self._parentmsgid)
def download_to_data(self):
downloader = self._client.getServiceNamed("downloader")
size=1000)
c = FakeClient()
cf = cachedir.CacheFile("none")
- fn1 = filenode.FileNode(u, c, cf)
+ fn1 = filenode.FileNode(u.to_string(), c, cf)
fn2 = filenode.FileNode(u.to_string(), c, cf)
self.failUnlessEqual(fn1, fn2)
self.failIfEqual(fn1, "I am not a filenode")