mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-26 17:06:51 +00:00
Revert "Update sync methods (#5467)"
This reverts commit 8d7930f660
.
See the discussion at https://github.com/Jermolene/TiddlyWiki5/pull/5467#issuecomment-873590578https://github.com/Jermolene/TiddlyWiki5/pull/5467#issuecomment-873590578
This commit is contained in:
parent
315464372f
commit
0b71f25f74
@ -601,10 +601,7 @@ SaveTiddlerTask.prototype.run = function(callback) {
|
||||
tiddler = this.syncer.wiki.tiddlerExists(this.title) && this.syncer.wiki.getTiddler(this.title);
|
||||
this.syncer.logger.log("Dispatching 'save' task:",this.title);
|
||||
if(tiddler) {
|
||||
this.syncer.syncadaptor.saveTiddler(tiddler,{
|
||||
changeCount: changeCount,
|
||||
tiddlerInfo: self.syncer.tiddlerInfo[self.title]
|
||||
},function(err,adaptorInfo,revision) {
|
||||
this.syncer.syncadaptor.saveTiddler(tiddler,function(err,adaptorInfo,revision) {
|
||||
// If there's an error, exit without changing any internal state
|
||||
if(err) {
|
||||
return callback(err);
|
||||
@ -618,6 +615,8 @@ SaveTiddlerTask.prototype.run = function(callback) {
|
||||
};
|
||||
// Invoke the callback
|
||||
callback(null);
|
||||
},{
|
||||
tiddlerInfo: self.syncer.tiddlerInfo[self.title]
|
||||
});
|
||||
} else {
|
||||
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) {
|
||||
var self = this;
|
||||
this.syncer.logger.log("Dispatching 'delete' task:",this.title);
|
||||
this.syncer.syncadaptor.deleteTiddler(this.title,{
|
||||
tiddlerInfo: self.syncer.tiddlerInfo[this.title]
|
||||
},function(err,adaptorInfo) {
|
||||
this.syncer.syncadaptor.deleteTiddler(this.title,function(err) {
|
||||
// If there's an error, exit without changing any internal state
|
||||
if(err) {
|
||||
return callback(err);
|
||||
@ -645,6 +642,8 @@ DeleteTiddlerTask.prototype.run = function(callback) {
|
||||
delete self.syncer.tiddlerInfo[self.title];
|
||||
// Invoke the callback
|
||||
callback(null);
|
||||
},{
|
||||
tiddlerInfo: self.syncer.tiddlerInfo[this.title]
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,7 @@ Returns a revision ID.
|
||||
Retrieves status information from the server. This method is optional.
|
||||
|
||||
|!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)`
|
||||
|
||||
@ -128,40 +128,33 @@ The syncer will use the `getUpdatedTiddlers()` method in preference to the `getS
|
||||
|!Parameter |!Description |
|
||||
|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.
|
||||
|
||||
|!Parameter |!Description |
|
||||
|tiddler |Tiddler to be saved |
|
||||
|options |See below |
|
||||
|callback |Callback function invoked with parameter `err,adaptorInfo,revision` |
|
||||
|tiddlerInfo |The tiddlerInfo maintained by the syncer for this tiddler |
|
||||
|
||||
!! `loadTiddler(title,options,callback)`
|
||||
!! `loadTiddler(title,callback)`
|
||||
|
||||
Loads a tiddler from the server.
|
||||
|
||||
|!Parameter |!Description |
|
||||
|title |Title of tiddler to be retrieved |
|
||||
|options |See below |
|
||||
|callback |Callback function invoked with parameter `err,tiddlerFields` |
|
||||
|
||||
!! `deleteTiddler(title,options,callback)`
|
||||
!! `deleteTiddler(title,callback,options)`
|
||||
|
||||
Delete a tiddler from the server.
|
||||
|
||||
|!Parameter |!Description |
|
||||
|title |Title of tiddler to be deleted |
|
||||
|options |See below |
|
||||
|callback |Callback function invoked with parameter `err` |
|
||||
|options |See below |
|
||||
|
||||
!!! Options
|
||||
|
||||
<<.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.
|
||||
The options parameter contains the following properties:
|
||||
|
||||
|!Property |!Description |
|
||||
|changeCount |The //new// changeCount value for this tiddler |
|
||||
|tiddlerInfo |The tiddlerInfo maintained by the syncer for this tiddler |
|
||||
|
@ -75,14 +75,7 @@ FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
|
||||
/*
|
||||
Save a tiddler and invoke the callback with (err,adaptorInfo,revision)
|
||||
*/
|
||||
FileSystemAdaptor.prototype.saveTiddler = function(tiddler,options,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 || {};
|
||||
FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback,options) {
|
||||
var self = this;
|
||||
var syncerInfo = options.tiddlerInfo || {};
|
||||
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.
|
||||
*/
|
||||
FileSystemAdaptor.prototype.loadTiddler = function(title,options,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 || {};
|
||||
FileSystemAdaptor.prototype.loadTiddler = function(title,callback) {
|
||||
callback(null,null);
|
||||
};
|
||||
|
||||
/*
|
||||
Delete a tiddler and invoke the callback with (err)
|
||||
*/
|
||||
FileSystemAdaptor.prototype.deleteTiddler = function(title,options,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 || {};
|
||||
FileSystemAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
||||
var self = this,
|
||||
fileInfo = this.boot.files[title];
|
||||
// Only delete the tiddler if we have writable information for the file
|
||||
|
@ -99,14 +99,7 @@ SaveTrailSyncAdaptor.prototype.getTiddlerInfo = function(tiddler) {
|
||||
/*
|
||||
Save a tiddler and invoke the callback with (err,adaptorInfo,revision)
|
||||
*/
|
||||
SaveTrailSyncAdaptor.prototype.saveTiddler = function(tiddler,options,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 || {};
|
||||
SaveTrailSyncAdaptor.prototype.saveTiddler = function(tiddler,callback) {
|
||||
if($tw.wiki.checkTiddlerText(ENABLE_TIDDLER_TITLE,"yes")) {
|
||||
var isDraft = $tw.utils.hop(tiddler.fields,"draft.of");
|
||||
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)
|
||||
*/
|
||||
SaveTrailSyncAdaptor.prototype.loadTiddler = function(title,options,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 || {};
|
||||
SaveTrailSyncAdaptor.prototype.loadTiddler = function(title,callback) {
|
||||
callback(null,null);
|
||||
};
|
||||
|
||||
/*
|
||||
Delete a tiddler and invoke the callback with (err)
|
||||
*/
|
||||
SaveTrailSyncAdaptor.prototype.deleteTiddler = function(title,options,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 || {};
|
||||
SaveTrailSyncAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
||||
callback(null,null);
|
||||
};
|
||||
|
||||
|
@ -182,14 +182,7 @@ TiddlyWebAdaptor.prototype.getSkinnyTiddlers = function(callback) {
|
||||
/*
|
||||
Save a tiddler and invoke the callback with (err,adaptorInfo,revision)
|
||||
*/
|
||||
TiddlyWebAdaptor.prototype.saveTiddler = function(tiddler,options,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 || {};
|
||||
TiddlyWebAdaptor.prototype.saveTiddler = function(tiddler,callback,options) {
|
||||
var self = this;
|
||||
if(this.isReadOnly) {
|
||||
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)
|
||||
*/
|
||||
TiddlyWebAdaptor.prototype.loadTiddler = function(title,options,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 || {};
|
||||
TiddlyWebAdaptor.prototype.loadTiddler = function(title,callback) {
|
||||
var self = this;
|
||||
$tw.utils.httpRequest({
|
||||
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:
|
||||
tiddlerInfo: the syncer's tiddlerInfo for this tiddler
|
||||
*/
|
||||
TiddlyWebAdaptor.prototype.deleteTiddler = function(title,options,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 || {};
|
||||
TiddlyWebAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
||||
var self = this;
|
||||
if(this.isReadOnly) {
|
||||
return callback(null,options.tiddlerInfo.adaptorInfo);
|
||||
|
Loading…
Reference in New Issue
Block a user