From 34f10d78fced8ddd5300b631d1fd0760fcbd7aa1 Mon Sep 17 00:00:00 2001 From: Adam- Date: Sun, 11 Apr 2010 07:29:51 +0000 Subject: [PATCH] Don't backup the database and not rewrite a new one (oops?) git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2887 5417fbe8-f217-4b02-8779-1006273d7864 --- src/core/db_plain.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index 0499b4fd4..2f20c3fe2 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -539,6 +539,13 @@ class DBPlain : public Module void BackupDatabase() { + /* Do not backup a database that doesn't exist */ + struct stat DBInfo; + if (stat(DatabaseFile.c_str(), &DBInfo)) + { + return; + } + time_t now = time(NULL); tm *tm = localtime(&now); @@ -887,6 +894,8 @@ class DBPlain : public Module EventReturn OnSaveDatabase() { + BackupDatabase(); + db.open(DatabaseFile.c_str(), std::ios_base::out | std::ios_base::trunc); if (!db.is_open()) @@ -1172,8 +1181,6 @@ class DBPlain : public Module db.close(); - BackupDatabase(); - return EVENT_CONTINUE; }