summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-04-11 07:29:51 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-04-11 07:29:51 +0000
commit34f10d78fced8ddd5300b631d1fd0760fcbd7aa1 (patch)
tree315b095657310060abf934ec8ed67a76dec16633
parent5d3491e72f9a88128a36ec47779e710b11525e94 (diff)
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
-rw-r--r--src/core/db_plain.cpp11
1 files 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;
}