Added check to ensure backup exists when restoring (#2779)

A check to ensure that the backup database exists before deleting the
current database.

Fixes #2778

Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com>
pull/2799/head
Matthew Nickson 1 year ago committed by GitHub
parent c19dcdba44
commit cd18b96f69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -496,6 +496,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)) {

Loading…
Cancel
Save