From: Daira Hopwood Date: Tue, 3 Nov 2015 02:53:57 +0000 (+0000) Subject: Workaround. X-Git-Url: https://git.rkrishnan.org/%5B/frontends/%22news.html/something?a=commitdiff_plain;h=a2e18bf43e978edbc491eff8afd1c208e69c6225;p=tahoe-lafs%2Ftahoe-lafs.git Workaround. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 0a5211ae..81502467 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -46,11 +46,13 @@ class MagicFolder(service.MultiService): name = 'magic-folder' def __init__(self, client, upload_dircap, collective_dircap, local_path_u, dbfile, - pending_delay=1.0, clock=reactor): + pending_delay=1.0, clock=None): precondition_abspath(local_path_u) service.MultiService.__init__(self) + immediate = clock is not None + clock = clock or reactor db = magicfolderdb.get_magicfolderdb(dbfile, create_version=(magicfolderdb.SCHEMA_v1, 1)) if db is None: return Failure(Exception('ERROR: Unable to load magic folder db.')) @@ -62,7 +64,7 @@ class MagicFolder(service.MultiService): upload_dirnode = self._client.create_node_from_uri(upload_dircap) collective_dirnode = self._client.create_node_from_uri(collective_dircap) - self.uploader = Uploader(client, local_path_u, db, upload_dirnode, pending_delay, clock) + self.uploader = Uploader(client, local_path_u, db, upload_dirnode, pending_delay, clock, immediate) self.downloader = Downloader(client, local_path_u, db, collective_dirnode, upload_dirnode.get_readonly_uri(), clock) def startService(self): @@ -163,10 +165,12 @@ class QueueMixin(HookMixin): class Uploader(QueueMixin): - def __init__(self, client, local_path_u, db, upload_dirnode, pending_delay, clock): + def __init__(self, client, local_path_u, db, upload_dirnode, pending_delay, clock, + immediate=False): QueueMixin.__init__(self, client, local_path_u, db, 'uploader', clock) self.is_ready = False + self._immediate = immediate if not IDirectoryNode.providedBy(upload_dirnode): raise AssertionError("The URI in '%s' does not refer to a directory." @@ -288,7 +292,10 @@ class Uploader(QueueMixin): self._pending.add(relpath_u) self._count('objects_queued') if self.is_ready: - self._clock.callLater(0, self._turn_deque) + if self._immediate: # for tests + self._turn_deque() + else: + self._clock.callLater(0, self._turn_deque) def _when_queue_is_empty(self): return defer.succeed(None) diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py index 960b031b..866958e8 100644 --- a/src/allmydata/test/test_cli_magic_folder.py +++ b/src/allmydata/test/test_cli_magic_folder.py @@ -115,15 +115,6 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): dbfile, pending_delay=0.2, clock=clock) magicfolder.downloader._turn_delay = 0 - orig = magicfolder.uploader._append_to_deque - # the _append_to_deque method queues a _turn_deque, so we - # immediately trigger it by wrapping _append_to_deque - def wrap(*args, **kw): - x = orig(*args, **kw) - clock.advance(0) # _turn_delay is always 0 for the tests - return x - magicfolder.uploader._append_to_deque = wrap - magicfolder.setServiceParent(self.get_client(client_num)) magicfolder.ready() return magicfolder