jeremy@jermolene.com 2021-07-05 19:26:20 +01:00
parent 315464372f
commit 0b71f25f74
5 changed files with 21 additions and 92 deletions

View File

@ -601,10 +601,7 @@ SaveTiddlerTask.prototype.run = function(callback) {
tiddler = this.syncer.wiki.tiddlerExists(this.title) && this.syncer.wiki.getTiddler(this.title); tiddler = this.syncer.wiki.tiddlerExists(this.title) && this.syncer.wiki.getTiddler(this.title);
this.syncer.logger.log("Dispatching 'save' task:",this.title); this.syncer.logger.log("Dispatching 'save' task:",this.title);
if(tiddler) { if(tiddler) {
this.syncer.syncadaptor.saveTiddler(tiddler,{ this.syncer.syncadaptor.saveTiddler(tiddler,function(err,adaptorInfo,revision) {
changeCount: changeCount,
tiddlerInfo: self.syncer.tiddlerInfo[self.title]
},function(err,adaptorInfo,revision) {
// If there's an error, exit without changing any internal state // If there's an error, exit without changing any internal state
if(err) { if(err) {
return callback(err); return callback(err);
@ -618,6 +615,8 @@ SaveTiddlerTask.prototype.run = function(callback) {
}; };
// Invoke the callback // Invoke the callback
callback(null); callback(null);
},{
tiddlerInfo: self.syncer.tiddlerInfo[self.title]
}); });
} else { } else {
this.syncer.logger.log(" Not Dispatching 'save' task:",this.title,"tiddler does not exist"); this.syncer.logger.log(" Not Dispatching 'save' task:",this.title,"tiddler does not exist");
@ -634,9 +633,7 @@ function DeleteTiddlerTask(syncer,title) {
DeleteTiddlerTask.prototype.run = function(callback) { DeleteTiddlerTask.prototype.run = function(callback) {
var self = this; var self = this;
this.syncer.logger.log("Dispatching 'delete' task:",this.title); this.syncer.logger.log("Dispatching 'delete' task:",this.title);
this.syncer.syncadaptor.deleteTiddler(this.title,{ this.syncer.syncadaptor.deleteTiddler(this.title,function(err) {
tiddlerInfo: self.syncer.tiddlerInfo[this.title]
},function(err,adaptorInfo) {
// If there's an error, exit without changing any internal state // If there's an error, exit without changing any internal state
if(err) { if(err) {
return callback(err); return callback(err);
@ -645,6 +642,8 @@ DeleteTiddlerTask.prototype.run = function(callback) {
delete self.syncer.tiddlerInfo[self.title]; delete self.syncer.tiddlerInfo[self.title];
// Invoke the callback // Invoke the callback
callback(null); callback(null);
},{
tiddlerInfo: self.syncer.tiddlerInfo[this.title]
}); });
}; };

View File

@ -69,7 +69,7 @@ Returns a revision ID.
Retrieves status information from the server. This method is optional. Retrieves status information from the server. This method is optional.
|!Parameter |!Description | |!Parameter |!Description |
|callback |Callback function invoked with parameters `err,isLoggedIn,username,isReadOnly,isAnonymous,isPollingDisabled` | |callback |Callback function invoked with parameters `err,isLoggedIn,username,isReadOnly` |
!! `login(username,password,callback)` !! `login(username,password,callback)`
@ -128,40 +128,33 @@ The syncer will use the `getUpdatedTiddlers()` method in preference to the `getS
|!Parameter |!Description | |!Parameter |!Description |
|callback |Callback function invoked with parameter `err,tiddlers`, where `tiddlers` is an array of tiddler field objects | |callback |Callback function invoked with parameter `err,tiddlers`, where `tiddlers` is an array of tiddler field objects |
!! `saveTiddler(tiddler,options,callback)` !! `saveTiddler(tiddler,callback)`
Saves a tiddler to the server. Saves a tiddler to the server.
|!Parameter |!Description | |!Parameter |!Description |
|tiddler |Tiddler to be saved | |tiddler |Tiddler to be saved |
|options |See below |
|callback |Callback function invoked with parameter `err,adaptorInfo,revision` | |callback |Callback function invoked with parameter `err,adaptorInfo,revision` |
|tiddlerInfo |The tiddlerInfo maintained by the syncer for this tiddler | |tiddlerInfo |The tiddlerInfo maintained by the syncer for this tiddler |
!! `loadTiddler(title,options,callback)` !! `loadTiddler(title,callback)`
Loads a tiddler from the server. Loads a tiddler from the server.
|!Parameter |!Description | |!Parameter |!Description |
|title |Title of tiddler to be retrieved | |title |Title of tiddler to be retrieved |
|options |See below |
|callback |Callback function invoked with parameter `err,tiddlerFields` | |callback |Callback function invoked with parameter `err,tiddlerFields` |
!! `deleteTiddler(title,options,callback)` !! `deleteTiddler(title,callback,options)`
Delete a tiddler from the server. Delete a tiddler from the server.
|!Parameter |!Description | |!Parameter |!Description |
|title |Title of tiddler to be deleted | |title |Title of tiddler to be deleted |
|options |See below |
|callback |Callback function invoked with parameter `err` | |callback |Callback function invoked with parameter `err` |
|options |See below |
!!! Options The options parameter contains the following properties:
<<.from-version "5.2.0">> The signature of syncadaptor functions that accept callbacks has been changed so that the callback is always the last argument. A check for the old order of arguments means that this change is backwards compatible. The new order should be prefered when updating or writing new plugins.
The options parameter may contain the following properties, depending on the method called.
|!Property |!Description | |!Property |!Description |
|changeCount |The //new// changeCount value for this tiddler |
|tiddlerInfo |The tiddlerInfo maintained by the syncer for this tiddler | |tiddlerInfo |The tiddlerInfo maintained by the syncer for this tiddler |

View File

@ -75,14 +75,7 @@ FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
/* /*
Save a tiddler and invoke the callback with (err,adaptorInfo,revision) Save a tiddler and invoke the callback with (err,adaptorInfo,revision)
*/ */
FileSystemAdaptor.prototype.saveTiddler = function(tiddler,options,callback) { FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback,options) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
var self = this; var self = this;
var syncerInfo = options.tiddlerInfo || {}; var syncerInfo = options.tiddlerInfo || {};
this.getTiddlerFileInfo(tiddler,function(err,fileInfo) { this.getTiddlerFileInfo(tiddler,function(err,fileInfo) {
@ -124,28 +117,14 @@ Load a tiddler and invoke the callback with (err,tiddlerFields)
We don't need to implement loading for the file system adaptor, because all the tiddler files will have been loaded during the boot process. We don't need to implement loading for the file system adaptor, because all the tiddler files will have been loaded during the boot process.
*/ */
FileSystemAdaptor.prototype.loadTiddler = function(title,options,callback) { FileSystemAdaptor.prototype.loadTiddler = function(title,callback) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
callback(null,null); callback(null,null);
}; };
/* /*
Delete a tiddler and invoke the callback with (err) Delete a tiddler and invoke the callback with (err)
*/ */
FileSystemAdaptor.prototype.deleteTiddler = function(title,options,callback) { FileSystemAdaptor.prototype.deleteTiddler = function(title,callback,options) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
var self = this, var self = this,
fileInfo = this.boot.files[title]; fileInfo = this.boot.files[title];
// Only delete the tiddler if we have writable information for the file // Only delete the tiddler if we have writable information for the file

View File

@ -99,14 +99,7 @@ SaveTrailSyncAdaptor.prototype.getTiddlerInfo = function(tiddler) {
/* /*
Save a tiddler and invoke the callback with (err,adaptorInfo,revision) Save a tiddler and invoke the callback with (err,adaptorInfo,revision)
*/ */
SaveTrailSyncAdaptor.prototype.saveTiddler = function(tiddler,options,callback) { SaveTrailSyncAdaptor.prototype.saveTiddler = function(tiddler,callback) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
if($tw.wiki.checkTiddlerText(ENABLE_TIDDLER_TITLE,"yes")) { if($tw.wiki.checkTiddlerText(ENABLE_TIDDLER_TITLE,"yes")) {
var isDraft = $tw.utils.hop(tiddler.fields,"draft.of"); var isDraft = $tw.utils.hop(tiddler.fields,"draft.of");
if(!isDraft || $tw.wiki.checkTiddlerText(ENABLE_DRAFTS_TIDDLER_TITLE,"yes")) { if(!isDraft || $tw.wiki.checkTiddlerText(ENABLE_DRAFTS_TIDDLER_TITLE,"yes")) {
@ -119,28 +112,14 @@ SaveTrailSyncAdaptor.prototype.saveTiddler = function(tiddler,options,callback)
/* /*
Load a tiddler and invoke the callback with (err,tiddlerFields) Load a tiddler and invoke the callback with (err,tiddlerFields)
*/ */
SaveTrailSyncAdaptor.prototype.loadTiddler = function(title,options,callback) { SaveTrailSyncAdaptor.prototype.loadTiddler = function(title,callback) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
callback(null,null); callback(null,null);
}; };
/* /*
Delete a tiddler and invoke the callback with (err) Delete a tiddler and invoke the callback with (err)
*/ */
SaveTrailSyncAdaptor.prototype.deleteTiddler = function(title,options,callback) { SaveTrailSyncAdaptor.prototype.deleteTiddler = function(title,callback,options) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
callback(null,null); callback(null,null);
}; };

View File

@ -182,14 +182,7 @@ TiddlyWebAdaptor.prototype.getSkinnyTiddlers = function(callback) {
/* /*
Save a tiddler and invoke the callback with (err,adaptorInfo,revision) Save a tiddler and invoke the callback with (err,adaptorInfo,revision)
*/ */
TiddlyWebAdaptor.prototype.saveTiddler = function(tiddler,options,callback) { TiddlyWebAdaptor.prototype.saveTiddler = function(tiddler,callback,options) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
var self = this; var self = this;
if(this.isReadOnly) { if(this.isReadOnly) {
return callback(null,options.tiddlerInfo.adaptorInfo); return callback(null,options.tiddlerInfo.adaptorInfo);
@ -223,14 +216,7 @@ TiddlyWebAdaptor.prototype.saveTiddler = function(tiddler,options,callback) {
/* /*
Load a tiddler and invoke the callback with (err,tiddlerFields) Load a tiddler and invoke the callback with (err,tiddlerFields)
*/ */
TiddlyWebAdaptor.prototype.loadTiddler = function(title,options,callback) { TiddlyWebAdaptor.prototype.loadTiddler = function(title,callback) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
var self = this; var self = this;
$tw.utils.httpRequest({ $tw.utils.httpRequest({
url: this.host + "recipes/" + encodeURIComponent(this.recipe) + "/tiddlers/" + encodeURIComponent(title), url: this.host + "recipes/" + encodeURIComponent(this.recipe) + "/tiddlers/" + encodeURIComponent(title),
@ -249,14 +235,7 @@ Delete a tiddler and invoke the callback with (err)
options include: options include:
tiddlerInfo: the syncer's tiddlerInfo for this tiddler tiddlerInfo: the syncer's tiddlerInfo for this tiddler
*/ */
TiddlyWebAdaptor.prototype.deleteTiddler = function(title,options,callback) { TiddlyWebAdaptor.prototype.deleteTiddler = function(title,callback,options) {
// Check for pre v5.2.0 method signature:
if(typeof callback !== "function" && typeof options === "function"){
var optionsArg = callback;
callback = options;
options = optionsArg;
}
options = options || {};
var self = this; var self = this;
if(this.isReadOnly) { if(this.isReadOnly) {
return callback(null,options.tiddlerInfo.adaptorInfo); return callback(null,options.tiddlerInfo.adaptorInfo);