From c3d18364c1b52cf89c1281b440d49f7df0d3a89a Mon Sep 17 00:00:00 2001 From: Jermolene Date: Tue, 5 Jul 2016 11:29:59 +0100 Subject: [PATCH] Don't use syncadaptors until they are ready Fixes #2453 --- core/modules/syncer.js | 4 ++-- plugins/tiddlywiki/filesystem/filesystemadaptor.js | 5 +++++ plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/modules/syncer.js b/core/modules/syncer.js index fc25e319d..d3481f69e 100644 --- a/core/modules/syncer.js +++ b/core/modules/syncer.js @@ -403,8 +403,8 @@ Process the task queue, performing the next task if appropriate */ Syncer.prototype.processTaskQueue = function() { var self = this; - // Only process a task if we're not already performing a task. If we are already performing a task then we'll dispatch the next one when it completes - if(this.numTasksInProgress() === 0) { + // Only process a task if the sync adaptor is fully initialised and we're not already performing a task. If we are already performing a task then we'll dispatch the next one when it completes + if(this.syncadaptor.isReady() && this.numTasksInProgress() === 0) { // Choose the next task to perform var task = this.chooseNextTask(); // Perform the task if we had one diff --git a/plugins/tiddlywiki/filesystem/filesystemadaptor.js b/plugins/tiddlywiki/filesystem/filesystemadaptor.js index 3f808e14f..34ff869b3 100644 --- a/plugins/tiddlywiki/filesystem/filesystemadaptor.js +++ b/plugins/tiddlywiki/filesystem/filesystemadaptor.js @@ -24,6 +24,11 @@ function FileSystemAdaptor(options) { $tw.utils.createDirectory($tw.boot.wikiTiddlersPath); } +FileSystemAdaptor.prototype.isReady = function() { + // The file system adaptor is always ready + return true; +}; + FileSystemAdaptor.prototype.getTiddlerInfo = function(tiddler) { return {}; }; diff --git a/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js b/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js index 3ff03f7a5..282c81dcc 100644 --- a/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js +++ b/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js @@ -19,9 +19,14 @@ function TiddlyWebAdaptor(options) { this.wiki = options.wiki; this.host = this.getHost(); this.recipe = undefined; + this.hasStatus = false; this.logger = new $tw.utils.Logger("TiddlyWebAdaptor"); } +TiddlyWebAdaptor.prototype.isReady = function() { + return this.hasStatus; +}; + TiddlyWebAdaptor.prototype.getHost = function() { var text = this.wiki.getTiddlerText(CONFIG_HOST_TIDDLER,DEFAULT_HOST_TIDDLER), substitutions = [ @@ -51,6 +56,7 @@ TiddlyWebAdaptor.prototype.getStatus = function(callback) { $tw.utils.httpRequest({ url: this.host + "status", callback: function(err,data) { + self.hasStatus = true; if(err) { return callback(err); }