From 3d608892bdd707a7b2c3d0f54843d37d516da007 Mon Sep 17 00:00:00 2001 From: Joshua Fontany Date: Fri, 26 Mar 2021 01:42:31 -0700 Subject: [PATCH] targeted fix for 5366 (#5416) --- core/modules/utils/filesystem.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/modules/utils/filesystem.js b/core/modules/utils/filesystem.js index 230090840..121cbc4c7 100644 --- a/core/modules/utils/filesystem.js +++ b/core/modules/utils/filesystem.js @@ -419,7 +419,7 @@ exports.saveTiddlerToFile = function(tiddler,fileInfo,callback) { if(fileInfo.hasMetaFile) { // Save the tiddler as a separate body and meta file var typeInfo = $tw.config.contentTypeInfo[tiddler.fields.type || "text/plain"] || {encoding: "utf8"}; - fs.writeFile(fileInfo.filepath,tiddler.fields.text,typeInfo.encoding,function(err) { + fs.writeFile(fileInfo.filepath,tiddler.fields.text || "",typeInfo.encoding,function(err) { if(err) { return callback(err); } @@ -461,7 +461,7 @@ exports.saveTiddlerToFileSync = function(tiddler,fileInfo) { if(fileInfo.hasMetaFile) { // Save the tiddler as a separate body and meta file var typeInfo = $tw.config.contentTypeInfo[tiddler.fields.type || "text/plain"] || {encoding: "utf8"}; - fs.writeFileSync(fileInfo.filepath,tiddler.fields.text,typeInfo.encoding); + fs.writeFileSync(fileInfo.filepath,tiddler.fields.text || "",typeInfo.encoding); fs.writeFileSync(fileInfo.filepath + ".meta",tiddler.getFieldStringBlock({exclude: ["text","bag"]}),"utf8"); } else { // Save the tiddler as a self contained templated file @@ -471,6 +471,7 @@ exports.saveTiddlerToFileSync = function(tiddler,fileInfo) { fs.writeFileSync(fileInfo.filepath,JSON.stringify([tiddler.getFieldStrings({exclude: ["bag"]})],null,$tw.config.preferences.jsonSpaces),"utf8"); } } + return fileInfo; }; /*