1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-22 18:24:51 +00:00

Fix crash loading large files

Attempts to load large files are neutered with a warning message

Is 100MB the right limit?
This commit is contained in:
Jeremy Ruston
2025-03-21 14:48:01 +00:00
parent 0b3efc2771
commit 55dbce10f4
2 changed files with 14 additions and 2 deletions

View File

@@ -1902,8 +1902,16 @@ $tw.loadTiddlersFromFile = function(filepath,fields) {
extensionInfo = $tw.utils.getFileExtensionInfo(ext),
type = extensionInfo ? extensionInfo.type : null,
typeInfo = type ? $tw.config.contentTypeInfo[type] : null,
data = fs.readFileSync(filepath,typeInfo ? typeInfo.encoding : "utf8"),
tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields),
fileSize = fs.statSync(filepath).size,
data;
if(fileSize > $tw.config.maxEditFileSize) {
data = "File " + filepath + "not loaded because it is too large";
console.log("Warning: " + data);
ext = ".txt";
} else {
data = fs.readFileSync(filepath,typeInfo ? typeInfo.encoding : "utf8");
}
var tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields),
metadata = $tw.loadMetadataForFile(filepath);
if(metadata) {
if(type === "application/json") {