From: David-Sarah Hopwood Date: Wed, 12 Dec 2012 07:04:31 +0000 (+0000) Subject: Miscellaneous corrections and additions. X-Git-Url: https://git.rkrishnan.org/vdrive/global?a=commitdiff_plain;h=86540abf2fbfc9a4f1cb84ce857ec7019769c20f;p=tahoe-lafs%2Ftahoe-lafs.git Miscellaneous corrections and additions. Signed-off-by: David-Sarah Hopwood --- diff --git a/src/allmydata/immutable/layout.py b/src/allmydata/immutable/layout.py index 8d9a8f03..5d0a70da 100644 --- a/src/allmydata/immutable/layout.py +++ b/src/allmydata/immutable/layout.py @@ -337,7 +337,7 @@ class ReadBucketProxy: return self._read(0, 0x44) def _parse_offsets(self, data): - precondition(len(data) >= 0x4) + precondition(len(data) >= 0x4, len(data)) self._offsets = {} (version,) = struct.unpack(">L", data[0:4]) if version != 1 and version != 2: diff --git a/src/allmydata/immutable/upload.py b/src/allmydata/immutable/upload.py index c6324046..55d2d4d0 100644 --- a/src/allmydata/immutable/upload.py +++ b/src/allmydata/immutable/upload.py @@ -815,8 +815,26 @@ class EncryptAnUploadable: self._status.set_progress(1, progress) return cryptdata - def get_plaintext_hashtree_leaves(self, first, last, num_segments): + """OBSOLETE; Get the leaf nodes of a merkle hash tree over the + plaintext segments, i.e. get the tagged hashes of the given segments. + The segment size is expected to be generated by the + IEncryptedUploadable before any plaintext is read or ciphertext + produced, so that the segment hashes can be generated with only a + single pass. + + This returns a Deferred that fires with a sequence of hashes, using: + + tuple(segment_hashes[first:last]) + + 'num_segments' is used to assert that the number of segments that the + IEncryptedUploadable handled matches the number of segments that the + encoder was expecting. + + This method must not be called until the final byte has been read + from read_encrypted(). Once this method is called, read_encrypted() + can never be called again. + """ # this is currently unused, but will live again when we fix #453 if len(self._plaintext_segment_hashes) < num_segments: # close out the last one @@ -835,6 +853,12 @@ class EncryptAnUploadable: return defer.succeed(tuple(self._plaintext_segment_hashes[first:last])) def get_plaintext_hash(self): + """OBSOLETE; Get the hash of the whole plaintext. + + This returns a Deferred that fires with a tagged SHA-256 hash of the + whole plaintext, obtained from hashutil.plaintext_hash(data). + """ + # this is currently unused, but will live again when we fix #453 h = self._plaintext_hasher.digest() return defer.succeed(h) diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index 62581be6..2594e5ed 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -1502,7 +1502,7 @@ class IDirectoryNode(IFilesystemNode): is empty, the metadata will be an empty dictionary. """ - def set_uri(name, writecap, readcap=None, metadata=None, overwrite=True): + def set_uri(name, writecap, readcap, metadata=None, overwrite=True): """I add a child (by writecap+readcap) at the specific name. I return a Deferred that fires when the operation finishes. If overwrite= is True, I will replace any existing child of the same name, otherwise diff --git a/src/allmydata/mutable/filenode.py b/src/allmydata/mutable/filenode.py index 50bbdd34..5757d796 100644 --- a/src/allmydata/mutable/filenode.py +++ b/src/allmydata/mutable/filenode.py @@ -742,8 +742,9 @@ class MutableFileVersion: """ return self._version[0] # verinfo[0] == the sequence number + def get_servermap(self): + return self._servermap - # TODO: Terminology? def get_writekey(self): """ I return a writekey or None if I don't have a writekey. diff --git a/src/allmydata/mutable/layout.py b/src/allmydata/mutable/layout.py index 7e20996f..f018ca7e 100644 --- a/src/allmydata/mutable/layout.py +++ b/src/allmydata/mutable/layout.py @@ -96,7 +96,7 @@ def unpack_header(data): return (version, seqnum, root_hash, IV, k, N, segsize, datalen, o) def unpack_share(data): - assert len(data) >= HEADER_LENGTH + assert len(data) >= HEADER_LENGTH, len(data) o = {} (version, seqnum, diff --git a/src/allmydata/storage/common.py b/src/allmydata/storage/common.py index 3a5e0dce..d2170426 100644 --- a/src/allmydata/storage/common.py +++ b/src/allmydata/storage/common.py @@ -1,12 +1,25 @@ -import os.path +import os, re + from allmydata.util import base32 + +# Share numbers match this regex: +NUM_RE=re.compile("^[0-9]+$") + +PREFIX = re.compile("^[%s]{2}$" % (base32.z_base_32_alphabet,)) + + class DataTooLargeError(Exception): pass -class UnknownMutableContainerVersionError(Exception): + +class UnknownContainerVersionError(Exception): + pass + +class UnknownMutableContainerVersionError(UnknownContainerVersionError): pass -class UnknownImmutableContainerVersionError(Exception): + +class UnknownImmutableContainerVersionError(UnknownContainerVersionError): pass diff --git a/src/allmydata/web/storage.py b/src/allmydata/web/storage.py index 19d40e18..59478b9e 100644 --- a/src/allmydata/web/storage.py +++ b/src/allmydata/web/storage.py @@ -40,7 +40,7 @@ class StorageStatus(rend.Page): def data_nickname(self, ctx, storage): return self.nickname def data_nodeid(self, ctx, storage): - return idlib.nodeid_b2a(self.storage.get_nodeid()) + return idlib.nodeid_b2a(self.storage.get_serverid()) def render_storage_running(self, ctx, storage): if storage: