Save uploaded data unchanged if Chub conversion fails for any reason
Avoid non-resolving promise in /characters/chats readline if chat file is empty
This commit is contained in:
parent
1819604f31
commit
457475baf1
|
@ -1027,6 +1027,12 @@ router.post('/chats', jsonParser, async function (request, response) {
|
||||||
const stats = fs.statSync(pathToFile);
|
const stats = fs.statSync(pathToFile);
|
||||||
const fileSizeInKB = `${(stats.size / 1024).toFixed(2)}kb`;
|
const fileSizeInKB = `${(stats.size / 1024).toFixed(2)}kb`;
|
||||||
|
|
||||||
|
if (stats.size === 0) {
|
||||||
|
console.log(`Found an empty chat file: ${pathToFile}`);
|
||||||
|
res({});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: fileStream,
|
input: fileStream,
|
||||||
crlfDelay: Infinity,
|
crlfDelay: Infinity,
|
||||||
|
|
|
@ -435,7 +435,7 @@ router.post('/import', urlencodedParser, function (request, response) {
|
||||||
|
|
||||||
// Do a tiny bit of work to import Chub Chat data
|
// Do a tiny bit of work to import Chub Chat data
|
||||||
// Processing the entire file is so fast that it's not worth checking if it's a Chub chat first
|
// Processing the entire file is so fast that it's not worth checking if it's a Chub chat first
|
||||||
let flattenedChat;
|
let flattenedChat = data;
|
||||||
try {
|
try {
|
||||||
// flattening is unlikely to break, but it's not worth failing to
|
// flattening is unlikely to break, but it's not worth failing to
|
||||||
// import normal chats in an attempt to import a Chub chat
|
// import normal chats in an attempt to import a Chub chat
|
||||||
|
|
Loading…
Reference in New Issue