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:
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, immediate)
+ self.uploader = Uploader(client, local_path_u, db, upload_dirnode, pending_delay, clock)
self.downloader = Downloader(client, local_path_u, db, collective_dirnode, upload_dirnode.get_readonly_uri(), clock)
def startService(self):
class Uploader(QueueMixin):
- def __init__(self, client, local_path_u, db, upload_dirnode, pending_delay, clock,
- immediate=False):
+ def __init__(self, client, local_path_u, db, upload_dirnode, pending_delay, clock):
QueueMixin.__init__(self, client, local_path_u, db, 'uploader', 0, clock)
self.is_ready = False
- self._immediate = immediate
+ self._advance_clock = lambda: None
if not IDirectoryNode.providedBy(upload_dirnode):
raise AssertionError("The URI in '%s' does not refer to a directory."
self._deque.append(relpath_u)
self._count('objects_queued')
if self.is_ready:
- if self._immediate: # for tests
- self._turn_deque()
- else:
- self._clock.callLater(0, self._turn_deque)
+ self._clock.callLater(0, self._turn_deque)
+ self._advance_clock()
- if self._immediate:
- _do_append()
- else:
- self._clock.callLater(self._pending_delay, _do_append)
+ self._clock.callLater(self._pending_delay, _do_append)
def _when_queue_is_empty(self):
return defer.succeed(None)
def init_magicfolder(self, client_num, upload_dircap, collective_dircap, local_magic_dir, clock):
dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.get_clientdir(i=client_num))
magicfolder = MagicFolder(self.get_client(client_num), upload_dircap, collective_dircap, local_magic_dir,
- dbfile, pending_delay=0.2, clock=clock)
+ dbfile, pending_delay=0.2, clock=clock)
+
+ magicfolder.uploader._advance_clock = lambda: clock.advance(0)
magicfolder.setServiceParent(self.get_client(client_num))
magicfolder.ready()