mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-29 14:38:52 +03:00
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>
This commit is contained in:
parent
c19dcdba44
commit
cd18b96f69
1 changed files with 10 additions and 0 deletions
|
@ -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…
Reference in a new issue