Fix 500 Internal Server Error with empty mods list.

This commit is contained in:
Dorian Niemiec 2024-08-06 16:16:06 +02:00
parent 03125d8b47
commit 928b0951b4

View file

@ -325,7 +325,7 @@ if (href == "/") {
parsedJsonData.mods.forEach(function (mod) {
entriesToInsert.push("(" + mysql.escape(results.insertId) + ", " + mysql.escape(mod.name) + ", " + mysql.escape(mod.version) + ")");
});
connection.query("INSERT INTO entries_mods (entry_id, name, version) VALUES " + entriesToInsert.join(", ") + ";", function (error, results, fields) {
connection.query(entriesToInsert.length > 0 ? ("INSERT INTO entries_mods (entry_id, name, version) VALUES " + entriesToInsert.join(", ") + ";") : "SELECT 1;", function (error, results, fields) {
if (error) {
serverconsole.errmessage("There was an error while processing the request!");
serverconsole.errmessage("Stack:");