mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 14:23:53 +00:00
Fix filesystem (#5465)
This commit is contained in:
parent
9f9ce6595b
commit
bfa062f23d
@ -158,11 +158,25 @@ WikiFolderMaker.prototype.saveCustomPlugin = function(pluginTiddler) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
WikiFolderMaker.prototype.saveTiddler = function(directory,tiddler) {
|
WikiFolderMaker.prototype.saveTiddler = function(directory,tiddler) {
|
||||||
|
var title = tiddler.fields.title, fileInfo, pathFilters, extFilters;
|
||||||
|
if(this.wiki.tiddlerExists("$:/config/FileSystemPaths")) {
|
||||||
|
pathFilters = this.wiki.getTiddlerText("$:/config/FileSystemPaths","").split("\n");
|
||||||
|
}
|
||||||
|
if(this.wiki.tiddlerExists("$:/config/FileSystemExtensions")) {
|
||||||
|
extFilters = this.wiki.getTiddlerText("$:/config/FileSystemExtensions","").split("\n");
|
||||||
|
}
|
||||||
var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
|
var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
|
||||||
directory: path.resolve(this.wikiFolderPath,directory),
|
directory: path.resolve(this.wikiFolderPath,directory),
|
||||||
wiki: this.wiki
|
wiki: this.wiki,
|
||||||
|
pathFilters: pathFilters,
|
||||||
|
extFilters: extFilters,
|
||||||
|
originalpath: this.wiki.extractTiddlerDataItem("$:/config/OriginalTiddlerPaths",title, "")
|
||||||
});
|
});
|
||||||
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);
|
try {
|
||||||
|
$tw.utils.saveTiddlerToFileSync(tiddler,fileInfo);
|
||||||
|
} catch (err) {
|
||||||
|
console.log("SaveWikiFolder: Error saving file '" + fileInfo.filepath + "', tiddler: '" + tiddler.fields.title);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
WikiFolderMaker.prototype.saveJSONFile = function(filename,json) {
|
WikiFolderMaker.prototype.saveJSONFile = function(filename,json) {
|
||||||
|
@ -640,10 +640,6 @@ DeleteTiddlerTask.prototype.run = function(callback) {
|
|||||||
}
|
}
|
||||||
// Remove the info stored about this tiddler
|
// Remove the info stored about this tiddler
|
||||||
delete self.syncer.tiddlerInfo[self.title];
|
delete self.syncer.tiddlerInfo[self.title];
|
||||||
if($tw.boot.files){
|
|
||||||
// Remove the tiddler from $tw.boot.files
|
|
||||||
delete $tw.boot.files[self.title];
|
|
||||||
}
|
|
||||||
// Invoke the callback
|
// Invoke the callback
|
||||||
callback(null);
|
callback(null);
|
||||||
},{
|
},{
|
||||||
|
@ -252,7 +252,7 @@ exports.generateTiddlerFileInfo = function(tiddler,options) {
|
|||||||
extFilters: options.extFilters,
|
extFilters: options.extFilters,
|
||||||
wiki: options.wiki
|
wiki: options.wiki
|
||||||
});
|
});
|
||||||
if(metaExt){
|
if(metaExt) {
|
||||||
if(metaExt === ".tid") {
|
if(metaExt === ".tid") {
|
||||||
// Overriding to the .tid extension needs special handling
|
// Overriding to the .tid extension needs special handling
|
||||||
fileInfo.type = "application/x-tiddler";
|
fileInfo.type = "application/x-tiddler";
|
||||||
@ -388,20 +388,18 @@ exports.generateTiddlerFilepath = function(title,options) {
|
|||||||
// If the last write failed with an error, or if path does not start with:
|
// If the last write failed with an error, or if path does not start with:
|
||||||
// the resolved options.directory, the resolved wikiPath directory, or the wikiTiddlersPath directory,
|
// the resolved options.directory, the resolved wikiPath directory, or the wikiTiddlersPath directory,
|
||||||
// then encodeURIComponent() and resolve to tiddler directory
|
// then encodeURIComponent() and resolve to tiddler directory
|
||||||
var newPath = fullPath,
|
var writePath = $tw.hooks.invokeHook("th-make-tiddler-path",fullPath),
|
||||||
encode = (options.fileInfo || {writeError: false}).writeError == true;
|
encode = (options.fileInfo || {writeError: false}).writeError == true;
|
||||||
if(!encode){
|
if(!encode) {
|
||||||
encode = !(fullPath.indexOf(path.resolve(directory)) == 0 ||
|
encode = !(fullPath.indexOf(path.resolve(directory)) == 0 ||
|
||||||
fullPath.indexOf(path.resolve($tw.boot.wikiPath)) == 0 ||
|
fullPath.indexOf(path.resolve($tw.boot.wikiPath)) == 0 ||
|
||||||
fullPath.indexOf($tw.boot.wikiTiddlersPath) == 0);
|
fullPath.indexOf($tw.boot.wikiTiddlersPath) == 0);
|
||||||
}
|
}
|
||||||
if(encode){
|
if(encode) {
|
||||||
fullPath = path.resolve(directory, encodeURIComponent(fullPath));
|
writePath = path.resolve(directory,encodeURIComponent(fullPath));
|
||||||
}
|
}
|
||||||
// Call hook to allow plugins to modify the final path
|
|
||||||
fullPath = $tw.hooks.invokeHook("th-make-tiddler-path", newPath, fullPath);
|
|
||||||
// Return the full path to the file
|
// Return the full path to the file
|
||||||
return fullPath;
|
return writePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -419,14 +417,29 @@ exports.saveTiddlerToFile = function(tiddler,fileInfo,callback) {
|
|||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
fs.writeFile(fileInfo.filepath + ".meta",tiddler.getFieldStringBlock({exclude: ["text","bag"]}),"utf8",callback);
|
fs.writeFile(fileInfo.filepath + ".meta",tiddler.getFieldStringBlock({exclude: ["text","bag"]}),"utf8",function(err) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
return callback(null,fileInfo);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Save the tiddler as a self contained templated file
|
// Save the tiddler as a self contained templated file
|
||||||
if(fileInfo.type === "application/x-tiddler") {
|
if(fileInfo.type === "application/x-tiddler") {
|
||||||
fs.writeFile(fileInfo.filepath,tiddler.getFieldStringBlock({exclude: ["text","bag"]}) + (!!tiddler.fields.text ? "\n\n" + tiddler.fields.text : ""),"utf8",callback);
|
fs.writeFile(fileInfo.filepath,tiddler.getFieldStringBlock({exclude: ["text","bag"]}) + (!!tiddler.fields.text ? "\n\n" + tiddler.fields.text : ""),"utf8",function(err) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
return callback(null,fileInfo);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
fs.writeFile(fileInfo.filepath,JSON.stringify([tiddler.getFieldStrings({exclude: ["bag"]})],null,$tw.config.preferences.jsonSpaces),"utf8",callback);
|
fs.writeFile(fileInfo.filepath,JSON.stringify([tiddler.getFieldStrings({exclude: ["bag"]})],null,$tw.config.preferences.jsonSpaces),"utf8",function(err) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
return callback(null,fileInfo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -457,10 +470,12 @@ exports.saveTiddlerToFileSync = function(tiddler,fileInfo) {
|
|||||||
/*
|
/*
|
||||||
Delete a file described by the fileInfo if it exits
|
Delete a file described by the fileInfo if it exits
|
||||||
*/
|
*/
|
||||||
exports.deleteTiddlerFile = function(fileInfo, callback) {
|
exports.deleteTiddlerFile = function(fileInfo,callback) {
|
||||||
//Only attempt to delete files that exist on disk
|
//Only attempt to delete files that exist on disk
|
||||||
if(!fileInfo.filepath || !fs.existsSync(fileInfo.filepath)) {
|
if(!fileInfo.filepath || !fs.existsSync(fileInfo.filepath)) {
|
||||||
return callback(null);
|
//For some reason, the tiddler is only in memory or we can't modify the file at this path
|
||||||
|
$tw.syncer.displayError("Server deleteTiddlerFile task failed for filepath: "+fileInfo.filepath);
|
||||||
|
return callback(null,fileInfo);
|
||||||
}
|
}
|
||||||
// Delete the file
|
// Delete the file
|
||||||
fs.unlink(fileInfo.filepath,function(err) {
|
fs.unlink(fileInfo.filepath,function(err) {
|
||||||
@ -473,10 +488,20 @@ exports.deleteTiddlerFile = function(fileInfo, callback) {
|
|||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
return $tw.utils.deleteEmptyDirs(path.dirname(fileInfo.filepath),callback);
|
return $tw.utils.deleteEmptyDirs(path.dirname(fileInfo.filepath),function(err) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
return callback(null,fileInfo);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return $tw.utils.deleteEmptyDirs(path.dirname(fileInfo.filepath),callback);
|
return $tw.utils.deleteEmptyDirs(path.dirname(fileInfo.filepath),function(err) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
return callback(null,fileInfo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -486,25 +511,25 @@ Cleanup old files on disk, by comparing the options values:
|
|||||||
adaptorInfo from $tw.syncer.tiddlerInfo
|
adaptorInfo from $tw.syncer.tiddlerInfo
|
||||||
bootInfo from $tw.boot.files
|
bootInfo from $tw.boot.files
|
||||||
*/
|
*/
|
||||||
exports.cleanupTiddlerFiles = function(options, callback) {
|
exports.cleanupTiddlerFiles = function(options,callback) {
|
||||||
var adaptorInfo = options.adaptorInfo || {},
|
var adaptorInfo = options.adaptorInfo || {},
|
||||||
bootInfo = options.bootInfo || {},
|
bootInfo = options.bootInfo || {},
|
||||||
title = options.title || "undefined";
|
title = options.title || "undefined";
|
||||||
if(adaptorInfo.filepath && bootInfo.filepath && adaptorInfo.filepath !== bootInfo.filepath) {
|
if(adaptorInfo.filepath && bootInfo.filepath && adaptorInfo.filepath !== bootInfo.filepath) {
|
||||||
return $tw.utils.deleteTiddlerFile(adaptorInfo, function(err){
|
$tw.utils.deleteTiddlerFile(adaptorInfo,function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
|
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
|
||||||
// Error deleting the previous file on disk, should fail gracefully
|
// Error deleting the previous file on disk, should fail gracefully
|
||||||
$tw.syncer.displayError("Server desynchronized. Error cleaning up previous file for tiddler: "+title, err);
|
$tw.syncer.displayError("Server desynchronized. Error cleaning up previous file for tiddler: \""+title+"\"",err);
|
||||||
return callback(null);
|
return callback(null,bootInfo);
|
||||||
} else {
|
} else {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return callback(null);
|
return callback(null,bootInfo);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return callback(null);
|
return callback(null,bootInfo);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ It is the responsibility of the filesystem adaptor to update this.boot.files for
|
|||||||
FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
|
FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
|
||||||
// Always generate a fileInfo object when this fuction is called
|
// Always generate a fileInfo object when this fuction is called
|
||||||
var title = tiddler.fields.title, newInfo, pathFilters, extFilters;
|
var title = tiddler.fields.title, newInfo, pathFilters, extFilters;
|
||||||
if(this.wiki.tiddlerExists("$:/config/FileSystemPaths")){
|
if(this.wiki.tiddlerExists("$:/config/FileSystemPaths")) {
|
||||||
pathFilters = this.wiki.getTiddlerText("$:/config/FileSystemPaths","").split("\n");
|
pathFilters = this.wiki.getTiddlerText("$:/config/FileSystemPaths","").split("\n");
|
||||||
}
|
}
|
||||||
if(this.wiki.tiddlerExists("$:/config/FileSystemExtensions")){
|
if(this.wiki.tiddlerExists("$:/config/FileSystemExtensions")) {
|
||||||
extFilters = this.wiki.getTiddlerText("$:/config/FileSystemExtensions","").split("\n");
|
extFilters = this.wiki.getTiddlerText("$:/config/FileSystemExtensions","").split("\n");
|
||||||
}
|
}
|
||||||
newInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
|
newInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{
|
||||||
@ -66,9 +66,8 @@ FileSystemAdaptor.prototype.getTiddlerFileInfo = function(tiddler,callback) {
|
|||||||
extFilters: extFilters,
|
extFilters: extFilters,
|
||||||
wiki: this.wiki,
|
wiki: this.wiki,
|
||||||
fileInfo: this.boot.files[title],
|
fileInfo: this.boot.files[title],
|
||||||
originalpath: this.wiki.extractTiddlerDataItem("$:/config/OriginalTiddlerPaths",title, "")
|
originalpath: this.wiki.extractTiddlerDataItem("$:/config/OriginalTiddlerPaths",title,"")
|
||||||
});
|
});
|
||||||
this.boot.files[title] = newInfo;
|
|
||||||
callback(null,newInfo);
|
callback(null,newInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,35 +75,38 @@ 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,callback) {
|
FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback,options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var syncerInfo = options.tiddlerInfo || {};
|
||||||
this.getTiddlerFileInfo(tiddler,function(err,fileInfo) {
|
this.getTiddlerFileInfo(tiddler,function(err,fileInfo) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
$tw.utils.saveTiddlerToFile(tiddler,fileInfo,function(err) {
|
$tw.utils.saveTiddlerToFile(tiddler,fileInfo,function(err,fileInfo) {
|
||||||
if(err) {
|
if(err) {
|
||||||
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "open") {
|
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "open") {
|
||||||
var bootInfo = self.boot.files[tiddler.fields.title];
|
fileInfo = fileInfo || self.boot.files[tiddler.fields.title];
|
||||||
bootInfo.writeError = true;
|
fileInfo.writeError = true;
|
||||||
self.boot.files[tiddler.fields.title] = bootInfo;
|
self.boot.files[tiddler.fields.title] = fileInfo;
|
||||||
$tw.syncer.displayError("Sync for tiddler [["+tiddler.fields.title+"]] will be retried with encoded filepath", encodeURIComponent(bootInfo.filepath));
|
$tw.syncer.logger.log("Sync failed for \""+tiddler.fields.title+"\" and will be retried with encoded filepath",encodeURIComponent(fileInfo.filepath));
|
||||||
return callback(err);
|
return callback(err);
|
||||||
} else {
|
} else {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Store new boot info only after successful writes
|
||||||
|
self.boot.files[tiddler.fields.title] = fileInfo;
|
||||||
// Cleanup duplicates if the file moved or changed extensions
|
// Cleanup duplicates if the file moved or changed extensions
|
||||||
var options = {
|
var options = {
|
||||||
adaptorInfo: ($tw.syncer.tiddlerInfo[tiddler.fields.title] || {adaptorInfo: {} }).adaptorInfo,
|
adaptorInfo: syncerInfo.adaptorInfo || {},
|
||||||
bootInfo: self.boot.files[tiddler.fields.title] || {},
|
bootInfo: fileInfo || {},
|
||||||
title: tiddler.fields.title
|
title: tiddler.fields.title
|
||||||
};
|
};
|
||||||
$tw.utils.cleanupTiddlerFiles(options, function(err){
|
$tw.utils.cleanupTiddlerFiles(options,function(err,fileInfo) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
return callback(null, self.boot.files[tiddler.fields.title]);
|
return callback(null,fileInfo);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -127,20 +129,22 @@ FileSystemAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
|||||||
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
|
||||||
if(fileInfo) {
|
if(fileInfo) {
|
||||||
$tw.utils.deleteTiddlerFile(fileInfo, function(err){
|
$tw.utils.deleteTiddlerFile(fileInfo,function(err,fileInfo) {
|
||||||
if(err) {
|
if(err) {
|
||||||
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
|
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
|
||||||
// Error deleting the file on disk, should fail gracefully
|
// Error deleting the file on disk, should fail gracefully
|
||||||
$tw.syncer.displayError("Server desynchronized. Error deleting file for deleted tiddler: "+title, err);
|
$tw.syncer.displayError("Server desynchronized. Error deleting file for deleted tiddler \"" + title + "\"",err);
|
||||||
return callback(null);
|
return callback(null,fileInfo);
|
||||||
} else {
|
} else {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return callback(null);
|
// Remove the tiddler from self.boot.files & return null adaptorInfo
|
||||||
|
delete self.boot.files[title];
|
||||||
|
return callback(null,null);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(null);
|
callback(null,null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ SaveTrailSyncAdaptor.prototype.saveTiddler = function(tiddler,callback) {
|
|||||||
saveTiddlerFile(tiddler,{reason: "modified"});
|
saveTiddlerFile(tiddler,{reason: "modified"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
callback(null);
|
callback(null,null);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -120,7 +120,7 @@ SaveTrailSyncAdaptor.prototype.loadTiddler = function(title,callback) {
|
|||||||
Delete a tiddler and invoke the callback with (err)
|
Delete a tiddler and invoke the callback with (err)
|
||||||
*/
|
*/
|
||||||
SaveTrailSyncAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
SaveTrailSyncAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
||||||
callback(null);
|
callback(null,null);
|
||||||
};
|
};
|
||||||
|
|
||||||
function saveTiddlerFile(tiddler,options) {
|
function saveTiddlerFile(tiddler,options) {
|
||||||
@ -139,8 +139,8 @@ function saveTiddlerFile(tiddler,options) {
|
|||||||
link.setAttribute("target","_blank");
|
link.setAttribute("target","_blank");
|
||||||
link.setAttribute("rel","noopener noreferrer");
|
link.setAttribute("rel","noopener noreferrer");
|
||||||
if(Blob !== undefined) {
|
if(Blob !== undefined) {
|
||||||
var blob = new Blob([text], {type: "text/plain"});
|
var blob = new Blob([text],{type: "text/plain"});
|
||||||
link.setAttribute("href", URL.createObjectURL(blob));
|
link.setAttribute("href",URL.createObjectURL(blob));
|
||||||
} else {
|
} else {
|
||||||
link.setAttribute("href","data:text/plain," + encodeURIComponent(text));
|
link.setAttribute("href","data:text/plain," + encodeURIComponent(text));
|
||||||
}
|
}
|
||||||
|
@ -182,10 +182,10 @@ 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,callback) {
|
TiddlyWebAdaptor.prototype.saveTiddler = function(tiddler,callback,options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if(this.isReadOnly) {
|
if(this.isReadOnly) {
|
||||||
return callback(null);
|
return callback(null,options.tiddlerInfo.adaptorInfo);
|
||||||
}
|
}
|
||||||
$tw.utils.httpRequest({
|
$tw.utils.httpRequest({
|
||||||
url: this.host + "recipes/" + encodeURIComponent(this.recipe) + "/tiddlers/" + encodeURIComponent(tiddler.fields.title),
|
url: this.host + "recipes/" + encodeURIComponent(this.recipe) + "/tiddlers/" + encodeURIComponent(tiddler.fields.title),
|
||||||
@ -207,7 +207,7 @@ TiddlyWebAdaptor.prototype.saveTiddler = function(tiddler,callback) {
|
|||||||
// Invoke the callback
|
// Invoke the callback
|
||||||
callback(null,{
|
callback(null,{
|
||||||
bag: etagInfo.bag
|
bag: etagInfo.bag
|
||||||
}, etagInfo.revision);
|
},etagInfo.revision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -238,12 +238,12 @@ tiddlerInfo: the syncer's tiddlerInfo for this tiddler
|
|||||||
TiddlyWebAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
TiddlyWebAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if(this.isReadOnly) {
|
if(this.isReadOnly) {
|
||||||
return callback(null);
|
return callback(null,options.tiddlerInfo.adaptorInfo);
|
||||||
}
|
}
|
||||||
// If we don't have a bag it means that the tiddler hasn't been seen by the server, so we don't need to delete it
|
// If we don't have a bag it means that the tiddler hasn't been seen by the server, so we don't need to delete it
|
||||||
var bag = options.tiddlerInfo.adaptorInfo && options.tiddlerInfo.adaptorInfo.bag;
|
var bag = options.tiddlerInfo.adaptorInfo && options.tiddlerInfo.adaptorInfo.bag;
|
||||||
if(!bag) {
|
if(!bag) {
|
||||||
return callback(null);
|
return callback(null,options.tiddlerInfo.adaptorInfo);
|
||||||
}
|
}
|
||||||
// Issue HTTP request to delete the tiddler
|
// Issue HTTP request to delete the tiddler
|
||||||
$tw.utils.httpRequest({
|
$tw.utils.httpRequest({
|
||||||
@ -253,8 +253,8 @@ TiddlyWebAdaptor.prototype.deleteTiddler = function(title,callback,options) {
|
|||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
// Invoke the callback
|
// Invoke the callback & return null adaptorInfo
|
||||||
callback(null);
|
callback(null,null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user