mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Don't crash the server on trying to display corrupted past chat
This commit is contained in:
@@ -1986,14 +1986,16 @@ app.post("/getallchatsofcharacter", jsonParser, function (request, response) {
|
|||||||
ii--;
|
ii--;
|
||||||
if (lastLine) {
|
if (lastLine) {
|
||||||
|
|
||||||
let jsonData = json5.parse(lastLine);
|
let jsonData = tryParse(lastLine);
|
||||||
if (jsonData.name !== undefined || jsonData.character_name !== undefined) {
|
if (jsonData && (jsonData.name !== undefined || jsonData.character_name !== undefined)) {
|
||||||
chatData[i] = {};
|
chatData[i] = {};
|
||||||
chatData[i]['file_name'] = file;
|
chatData[i]['file_name'] = file;
|
||||||
chatData[i]['file_size'] = fileSizeInKB;
|
chatData[i]['file_size'] = fileSizeInKB;
|
||||||
chatData[i]['chat_items'] = itemCounter - 1;
|
chatData[i]['chat_items'] = itemCounter - 1;
|
||||||
chatData[i]['mes'] = jsonData['mes'] || '[The chat is empty]';
|
chatData[i]['mes'] = jsonData['mes'] || '[The chat is empty]';
|
||||||
chatData[i]['last_mes'] = jsonData['send_date'] || Date.now();
|
chatData[i]['last_mes'] = jsonData['send_date'] || Date.now();
|
||||||
|
} else {
|
||||||
|
console.log('Found an invalid or corrupted chat file: ' + fullPathAndFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ii === 0) {
|
if (ii === 0) {
|
||||||
|
Reference in New Issue
Block a user