diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-05-14 20:52:17 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-05-14 20:52:17 +0000 |
commit | 5993a65b87ecf794158dca1ac2602c1755c2a27e (patch) | |
tree | acc99878b60d229d65e2daa24c39879900476acb /src/core/db_plain.cpp | |
parent | 116a4b2bea556911239f735c467c7b6f1415c0a7 (diff) |
Fixed many windows problems in the debug build
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2960 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core/db_plain.cpp')
-rw-r--r-- | src/core/db_plain.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp index eca3b3791..dc9733023 100644 --- a/src/core/db_plain.cpp +++ b/src/core/db_plain.cpp @@ -52,6 +52,11 @@ static void ReadDatabase(Module *m = NULL) return; } + NickCore *nc = NULL; + NickAlias *na = NULL; + BotInfo *bi = NULL; + ChannelInfo *ci = NULL; + while (std::getline(db, buf)) { if (buf.empty()) @@ -84,10 +89,6 @@ static void ReadDatabase(Module *m = NULL) continue; std::string mdbuf; - NickCore *nc; - NickAlias *na; - BotInfo *bi; - ChannelInfo *ci; if (!params.empty()) { if (params[0] == "NC") @@ -116,7 +117,7 @@ static void ReadDatabase(Module *m = NULL) params.erase(params.begin()); params.erase(params.begin()); - if (nc && Type == MD_NC) + if (Type == MD_NC && nc) { try { @@ -132,7 +133,7 @@ static void ReadDatabase(Module *m = NULL) Alog() << "[db_plain]: " << ex.GetReason(); } } - else if (na && Type == MD_NA) + else if (Type == MD_NA && na) { try { @@ -148,7 +149,7 @@ static void ReadDatabase(Module *m = NULL) Alog() << "[db_plain]: " << ex.GetReason(); } } - else if (bi && Type == MD_BI) + else if (Type == MD_BI && bi) { try { @@ -164,7 +165,7 @@ static void ReadDatabase(Module *m = NULL) Alog() << "[db_plain]: " << ex.GetReason(); } } - else if (ci && Type == MD_CH) + else if (Type == MD_CH && ci) { try { @@ -571,6 +572,15 @@ class DBPlain : public Module char *newname = new char[DatabaseFile.length() + 30]; snprintf(newname, DatabaseFile.length() + 30, "backups/%s.%d%d%d", DatabaseFile.c_str(), tm->tm_year, tm->tm_mon, tm->tm_mday); + /* Backup already exists */ + if (!stat(newname, &DBInfo)) + { + delete [] newname; + return; + } + Alog() << "it.. doesnt exist?"; + + Alog(LOG_DEBUG) << "db_plain: Attemping to rename " << DatabaseFile << " to " << newname; if (rename(DatabaseFile.c_str(), newname) != 0) { ircdproto->SendGlobops(findbot(Config.s_OperServ), "Unable to backup database!"); @@ -579,6 +589,8 @@ class DBPlain : public Module if (!Config.NoBackupOkay) quitting = 1; + delete [] newname; + return; } |