From 69b86ebe9abcd15aa49f3081dfb08d0ce8f85d6e Mon Sep 17 00:00:00 2001 From: meejah Date: Mon, 8 Aug 2016 19:39:19 -0600 Subject: [PATCH] Improve startup error-reporting This keeps re-trying the initial magic-folder scan and alerts the user (via logs only :/) until it succeeds at least once. After this happens and the node has started up, it will continue to re-try if enough storage servers go away later such that the remote collection can't be retrieved. --- src/allmydata/frontends/magic_folder.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index c34087390..a2a6053e7 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -7,6 +7,7 @@ import time from twisted.internet import defer, reactor, task from twisted.python.failure import Failure from twisted.python import runtime +from twisted.python import log as twlog from twisted.application import service from zope.interface import Interface, Attribute, implementer @@ -92,7 +93,7 @@ class MagicFolder(service.MultiService): """ready is used to signal us to start processing the upload and download items... """ - self.uploader.start_uploading() # synchronous + self.uploader.start_uploading() # synchronous, returns None return self.downloader.start_downloading() def finish(self): @@ -731,16 +732,24 @@ class Downloader(QueueMixin, WriteFileMixin): self._is_upload_pending = is_upload_pending self._umask = umask + @defer.inlineCallbacks def start_downloading(self): self._log("start_downloading") self._turn_delay = self.scan_interval files = self._db.get_all_relpaths() self._log("all files %s" % files) - d = self._scan_remote_collective(scan_self=True) - d.addBoth(self._logcb, "after _scan_remote_collective 0") - d.addCallback(self._begin_processing) - return d + while True: + try: + data = yield self._scan_remote_collective(scan_self=True) + twlog.msg("Completed initial Magic Folder scan successfully") + x = yield self._begin_processing(data) + defer.returnValue(x) + break + + except Exception as e: + twlog.msg("Magic Folder failed initial scan: %s" % (e,)) + yield task.deferLater(self._clock, self.scan_interval, lambda: None) def stop(self): self._log("stop") @@ -884,6 +893,7 @@ class Downloader(QueueMixin, WriteFileMixin): try: x = yield self._scan(None) except Exception as e: + twlog.msg("Remote scan failed: %s" % (e,)) self._log("_scan failed: %s" % (repr(e),)) defer.returnValue(x)