Correct magic-folder use of StorageFarmBroker

When landing the "connected enough" changes on master,
we changed the API; this fixes up usage of it in magic-folder.
This commit is contained in:
meejah 2016-05-02 14:54:05 -06:00 committed by Brian Warner
parent e67d23b8fa
commit 58f9641179
4 changed files with 14 additions and 9 deletions

View File

@ -121,7 +121,6 @@ class Client(node.Node, pollmixin.PollMixin):
} }
def __init__(self, basedir="."): def __init__(self, basedir="."):
#print "Client.__init__(%r)" % (basedir,)
node.Node.__init__(self, basedir) node.Node.__init__(self, basedir)
# All tub.registerReference must happen *after* we upcall, since # All tub.registerReference must happen *after* we upcall, since
# that's what does tub.setLocation() # that's what does tub.setLocation()
@ -374,11 +373,6 @@ class Client(node.Node, pollmixin.PollMixin):
self.storage_broker = sb self.storage_broker = sb
sb.setServiceParent(self) sb.setServiceParent(self)
connection_threshold = min(self.encoding_params["k"],
self.encoding_params["happy"] + 1)
helper = storage_client.ConnectedEnough(sb, connection_threshold)
self.connected_enough_d = helper.when_connected_enough()
# utilize the loaded static server specifications # utilize the loaded static server specifications
for key, server in self.connections_config['servers'].items(): for key, server in self.connections_config['servers'].items():
eventually(self.storage_broker.got_static_announcement, eventually(self.storage_broker.got_static_announcement,
@ -498,7 +492,13 @@ class Client(node.Node, pollmixin.PollMixin):
s.startService() s.startService()
# start processing the upload queue when we've connected to enough servers # start processing the upload queue when we've connected to enough servers
self.connected_enough_d.addCallback(lambda ign: s.ready()) connection_threshold = min(self.encoding_params["k"],
self.encoding_params["happy"] + 1)
connected = storage_client.ConnectedEnough(
self.storage_broker,
connection_threshold,
)
connected.when_connected_enough().addCallback(lambda ign: s.ready())
def _check_exit_trigger(self, exit_trigger_file): def _check_exit_trigger(self, exit_trigger_file):
if os.path.exists(exit_trigger_file): if os.path.exists(exit_trigger_file):

View File

@ -127,7 +127,10 @@ node_id = 0
for name in ['alice', 'bob']: for name in ['alice', 'bob']:
data_dir = join(data_base, name) data_dir = join(data_base, name)
magic_dir = join(data_base, '%s-magic' % (name,)) magic_dir = join(data_base, '%s-magic' % (name,))
mkdir(magic_dir) try:
mkdir(magic_dir)
except OSError:
pass
if not exists(data_dir): if not exists(data_dir):
do_invites = True do_invites = True
subprocess.check_call( subprocess.check_call(

View File

@ -175,6 +175,8 @@ class NoNetworkStorageBroker:
return self.client._servers return self.client._servers
def get_nickname_for_serverid(self, serverid): def get_nickname_for_serverid(self, serverid):
return None return None
def on_servers_changed(self, cb):
pass
class NoNetworkClient(Client): class NoNetworkClient(Client):

View File

@ -248,7 +248,7 @@ class Basic(testutil.ReallyEqualMixin, testutil.NonASCIIPathMixin, unittest.Test
self.failUnlessReallyEqual(self._permute(sb, "one"), []) self.failUnlessReallyEqual(self._permute(sb, "one"), [])
def test_permute_with_preferred(self): def test_permute_with_preferred(self):
sb = StorageFarmBroker(True, ['1','4']) sb = StorageFarmBroker(True, preferred_peers=['1','4'])
for k in ["%d" % i for i in range(5)]: for k in ["%d" % i for i in range(5)]:
ann = {"anonymous-storage-FURL": "pb://abcde@nowhere/fake", ann = {"anonymous-storage-FURL": "pb://abcde@nowhere/fake",
"permutation-seed-base32": base32.b2a(k) } "permutation-seed-base32": base32.b2a(k) }