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.
This commit is contained in:
meejah 2016-08-08 19:39:19 -06:00 committed by Brian Warner
parent fd978bfed6
commit 69b86ebe9a

View File

@ -7,6 +7,7 @@ import time
from twisted.internet import defer, reactor, task from twisted.internet import defer, reactor, task
from twisted.python.failure import Failure from twisted.python.failure import Failure
from twisted.python import runtime from twisted.python import runtime
from twisted.python import log as twlog
from twisted.application import service from twisted.application import service
from zope.interface import Interface, Attribute, implementer from zope.interface import Interface, Attribute, implementer
@ -92,7 +93,7 @@ class MagicFolder(service.MultiService):
"""ready is used to signal us to start """ready is used to signal us to start
processing the upload and download items... processing the upload and download items...
""" """
self.uploader.start_uploading() # synchronous self.uploader.start_uploading() # synchronous, returns None
return self.downloader.start_downloading() return self.downloader.start_downloading()
def finish(self): def finish(self):
@ -731,16 +732,24 @@ class Downloader(QueueMixin, WriteFileMixin):
self._is_upload_pending = is_upload_pending self._is_upload_pending = is_upload_pending
self._umask = umask self._umask = umask
@defer.inlineCallbacks
def start_downloading(self): def start_downloading(self):
self._log("start_downloading") self._log("start_downloading")
self._turn_delay = self.scan_interval self._turn_delay = self.scan_interval
files = self._db.get_all_relpaths() files = self._db.get_all_relpaths()
self._log("all files %s" % files) self._log("all files %s" % files)
d = self._scan_remote_collective(scan_self=True) while True:
d.addBoth(self._logcb, "after _scan_remote_collective 0") try:
d.addCallback(self._begin_processing) data = yield self._scan_remote_collective(scan_self=True)
return d 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): def stop(self):
self._log("stop") self._log("stop")
@ -884,6 +893,7 @@ class Downloader(QueueMixin, WriteFileMixin):
try: try:
x = yield self._scan(None) x = yield self._scan(None)
except Exception as e: except Exception as e:
twlog.msg("Remote scan failed: %s" % (e,))
self._log("_scan failed: %s" % (repr(e),)) self._log("_scan failed: %s" % (repr(e),))
defer.returnValue(x) defer.returnValue(x)