Merge remote-tracking branch 'remote/master' into feature/add-xml-support-to-http-monitors

This commit is contained in:
Faruk Genç
2023-02-18 22:38:40 +03:00
48 changed files with 2764 additions and 268 deletions

View File

@@ -497,6 +497,16 @@ class Database {
const shmPath = Database.path + "-shm";
const walPath = Database.path + "-wal";
// Make sure we have a backup to restore before deleting old db
if (
!fs.existsSync(this.backupPath)
&& !fs.existsSync(shmPath)
&& !fs.existsSync(walPath)
) {
log.error("db", "Backup file not found! Leaving database in failed state.");
process.exit(1);
}
// Delete patch failed db
try {
if (fs.existsSync(Database.path)) {

View File

@@ -292,14 +292,23 @@ exports.postgresQuery = function (connectionString, query) {
client.end();
} else {
// Connected here
client.query(query, (err, res) => {
if (err) {
reject(err);
} else {
resolve(res);
try {
// No query provided by user, use SELECT 1
if (!query || (typeof query === "string" && query.trim() === "")) {
query = "SELECT 1";
}
client.end();
});
client.query(query, (err, res) => {
if (err) {
reject(err);
} else {
resolve(res);
}
client.end();
});
} catch (e) {
reject(e);
}
}
});