1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

AWS Plugin: Fix crash when attempting to save a missing tiddler

This commit is contained in:
Jermolene 2017-09-15 14:15:56 +01:00
parent 24c325611b
commit 7a714da9cb

View File

@ -132,7 +132,7 @@ Command.prototype.subCommands["s3-rendertiddlers"] = function() {
saveTypeFilter = this.params[7] || "[[" + type + "]]", saveTypeFilter = this.params[7] || "[[" + type + "]]",
tiddlers = wiki.filterTiddlers(filter); tiddlers = wiki.filterTiddlers(filter);
// Check parameters // Check parameters
if(!filter || !template || !region || !bucket || !filenameFilter) { if(!filter || !region || !bucket || !filenameFilter) {
throw "Missing parameters"; throw "Missing parameters";
} }
async.eachLimit( async.eachLimit(
@ -210,12 +210,16 @@ Command.prototype.subCommands["s3-savetiddlers"] = function() {
tiddlers, tiddlers,
20, 20,
function(title,callback) { function(title,callback) {
var tiddler = wiki.getTiddler(title), var tiddler = wiki.getTiddler(title);
text = tiddler.fields.text || "", if(tiddler) {
var text = tiddler.fields.text || "",
type = tiddler.fields.type || "text/vnd.tiddlywiki", type = tiddler.fields.type || "text/vnd.tiddlywiki",
filename = wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0], filename = wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0],
saveType = wiki.filterTiddlers(saveTypeFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]; saveType = wiki.filterTiddlers(saveTypeFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0];
awsUtils.putFile(region,bucket,filename,text,saveType || type,callback); awsUtils.putFile(region,bucket,filename,text,saveType || type,callback);
} else {
process.nextTick(callback,null);
}
}, },
function(err,results) { function(err,results) {
self.callback(err,results); self.callback(err,results);