summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-10-27 09:09:33 -0400
committerAdam <Adam@anope.org>2012-10-27 09:09:33 -0400
commitdf2ee078aa3c3830ae7365a920faa502d97c66d1 (patch)
tree03b3f541143c0de4a03d059439bc482a7869fcd1 /src
parent3f4349f54ad8b7fee75fc1256e12d4eda9de5744 (diff)
Issue #346 - fix m_permchannels.cpp and m_xline_db.cpp saving their databases on Windows due to rename() failing if the destination file exists
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_permchannels.cpp8
-rw-r--r--src/modules/m_xline_db.cpp8
2 files changed, 16 insertions, 0 deletions
diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp
index 6f67cc31d..40774e1fa 100644
--- a/src/modules/m_permchannels.cpp
+++ b/src/modules/m_permchannels.cpp
@@ -100,6 +100,14 @@ static bool WriteDatabase()
return false;
}
+#ifdef _WIN32
+ if (remove(permchannelsconf.c_str()))
+ {
+ ServerInstance->Logs->Log("m_permchannels",DEFAULT, "permchannels: Cannot remove old database! %s (%d)", strerror(errno), errno);
+ ServerInstance->SNO->WriteToSnoMask('a', "database: cannot remove old database: %s (%d)", strerror(errno), errno);
+ return false;
+ }
+#endif
// Use rename to move temporary to new db - this is guarenteed not to fuck up, even in case of a crash.
if (rename(tempname.c_str(), permchannelsconf.c_str()) < 0)
{
diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp
index 21c75f45e..6caae07d7 100644
--- a/src/modules/m_xline_db.cpp
+++ b/src/modules/m_xline_db.cpp
@@ -152,6 +152,14 @@ class ModuleXLineDB : public Module
return false;
}
+#ifdef _WIN32
+ if (remove(xlinedbpath.c_str()))
+ {
+ ServerInstance->Logs->Log("m_xline_db",DEBUG, "xlinedb: Cannot remove old database! %s (%d)", strerror(errno), errno);
+ ServerInstance->SNO->WriteToSnoMask('a', "database: cannot remove old database: %s (%d)", strerror(errno), errno);
+ return false;
+ }
+#endif
// Use rename to move temporary to new db - this is guarenteed not to fuck up, even in case of a crash.
if (rename(xlinenewdbpath.c_str(), xlinedbpath.c_str()) < 0)
{