mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-07 11:50:21 +00:00
filenode: add get_repair_cap(), which uses the read-write filecap for immutable files, and the verifycap for immutable files
This commit is contained in:
parent
824edc438f
commit
d8b3505cf5
@ -192,6 +192,10 @@ class FileNode(_ImmutableFileNodeBase, log.PrefixingLogMixin):
|
|||||||
def get_verify_cap(self):
|
def get_verify_cap(self):
|
||||||
return self.u.get_verify_cap()
|
return self.u.get_verify_cap()
|
||||||
|
|
||||||
|
def get_repair_cap(self):
|
||||||
|
# CHK files can be repaired with just the verifycap
|
||||||
|
return self.u.get_verify_cap()
|
||||||
|
|
||||||
def get_storage_index(self):
|
def get_storage_index(self):
|
||||||
return self.u.storage_index
|
return self.u.storage_index
|
||||||
|
|
||||||
@ -298,6 +302,9 @@ class LiteralFileNode(_ImmutableFileNodeBase):
|
|||||||
def get_verify_cap(self):
|
def get_verify_cap(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_repair_cap(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def get_storage_index(self):
|
def get_storage_index(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -424,6 +424,14 @@ class IFilesystemNode(Interface):
|
|||||||
get_readonly_uri() will return the same thing as get_uri().
|
get_readonly_uri() will return the same thing as get_uri().
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def get_repair_cap():
|
||||||
|
"""Return an IURI instance that can be used to repair the file, or
|
||||||
|
None if this node cannot be repaired (either because it is not
|
||||||
|
distributed, like a LIT file, or because the node does not represent
|
||||||
|
sufficient authority to create a repair-cap, like a read-only RSA
|
||||||
|
mutable file node [which cannot create the correct write-enablers]).
|
||||||
|
"""
|
||||||
|
|
||||||
def get_verify_cap():
|
def get_verify_cap():
|
||||||
"""Return an IVerifierURI instance that represents the
|
"""Return an IVerifierURI instance that represents the
|
||||||
'verifiy/refresh capability' for this node. The holder of this
|
'verifiy/refresh capability' for this node. The holder of this
|
||||||
|
@ -220,6 +220,11 @@ class MutableFileNode:
|
|||||||
def get_verify_cap(self):
|
def get_verify_cap(self):
|
||||||
return IMutableFileURI(self._uri).get_verify_cap()
|
return IMutableFileURI(self._uri).get_verify_cap()
|
||||||
|
|
||||||
|
def get_repair_cap(self):
|
||||||
|
if self._uri.is_readonly():
|
||||||
|
return None
|
||||||
|
return self._uri
|
||||||
|
|
||||||
def _do_serialized(self, cb, *args, **kwargs):
|
def _do_serialized(self, cb, *args, **kwargs):
|
||||||
# note: to avoid deadlock, this callable is *not* allowed to invoke
|
# note: to avoid deadlock, this callable is *not* allowed to invoke
|
||||||
# other serialized methods within this (or any other)
|
# other serialized methods within this (or any other)
|
||||||
|
@ -42,6 +42,7 @@ class Node(unittest.TestCase):
|
|||||||
d[fn1] = 1 # exercise __hash__
|
d[fn1] = 1 # exercise __hash__
|
||||||
v = fn1.get_verify_cap()
|
v = fn1.get_verify_cap()
|
||||||
self.failUnless(isinstance(v, uri.CHKFileVerifierURI))
|
self.failUnless(isinstance(v, uri.CHKFileVerifierURI))
|
||||||
|
self.failUnlessEqual(fn1.get_repair_cap(), v)
|
||||||
|
|
||||||
|
|
||||||
def test_literal_filenode(self):
|
def test_literal_filenode(self):
|
||||||
@ -64,6 +65,7 @@ class Node(unittest.TestCase):
|
|||||||
|
|
||||||
v = fn1.get_verify_cap()
|
v = fn1.get_verify_cap()
|
||||||
self.failUnlessEqual(v, None)
|
self.failUnlessEqual(v, None)
|
||||||
|
self.failUnlessEqual(fn1.get_repair_cap(), None)
|
||||||
|
|
||||||
d = fn1.download(download.Data())
|
d = fn1.download(download.Data())
|
||||||
def _check(res):
|
def _check(res):
|
||||||
@ -124,9 +126,11 @@ class Node(unittest.TestCase):
|
|||||||
self.failUnlessEqual(nro_u, u.get_readonly().to_string())
|
self.failUnlessEqual(nro_u, u.get_readonly().to_string())
|
||||||
self.failUnlessEqual(nro.is_mutable(), True)
|
self.failUnlessEqual(nro.is_mutable(), True)
|
||||||
self.failUnlessEqual(nro.is_readonly(), True)
|
self.failUnlessEqual(nro.is_readonly(), True)
|
||||||
|
self.failUnlessEqual(nro.get_repair_cap(), None) # RSAmut needs writecap
|
||||||
|
|
||||||
v = n.get_verify_cap()
|
v = n.get_verify_cap()
|
||||||
self.failUnless(isinstance(v, uri.SSKVerifierURI))
|
self.failUnless(isinstance(v, uri.SSKVerifierURI))
|
||||||
|
self.failUnlessEqual(n.get_repair_cap(), n._uri) # TODO: n.get_uri()
|
||||||
|
|
||||||
class LiteralChecker(unittest.TestCase):
|
class LiteralChecker(unittest.TestCase):
|
||||||
def test_literal_filenode(self):
|
def test_literal_filenode(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user