Only save a single backup of the znc config file

The ~/.znc/configs/backups/ directory quickly got quite big, so we don't do
that but instead only save on backup as ~/.znc/configs/znc.conf-backup


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@975 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-03-01 16:30:08 +00:00
parent e0cfd7958e
commit f6d86fac43
2 changed files with 20 additions and 6 deletions
+18 -4
View File
@@ -412,7 +412,6 @@ void CZNC::InitDirs(const CString& sArgvPath, const CString& sDataDir) {
// Other dirs that we use
m_sConfPath = m_sZNCPath + "/configs";
m_sConfBackupPath = m_sConfPath + "/backups";
m_sModPath = m_sZNCPath + "/modules";
m_sUserPath = m_sZNCPath + "/users";
}
@@ -436,10 +435,25 @@ CString CZNC::ExpandConfigPath(const CString& sConfigFile) {
return sRetPath;
}
bool CZNC::WriteConfig() {
CFile File(m_sConfigFile);
bool CZNC::BackupConfig() const {
CString sBackup = GetConfigFile() + "-backup";
if (!File.Copy(GetConfBackupPath() + "/" + File.GetShortName() + "-" + CString(time(NULL)))) {
// Create a new backup overwriting an old one we might have
if (CFile::Copy(m_sConfigFile, sBackup, true))
return true;
// Don't abort if no config file exists
if (!CFile::Exists(m_sConfigFile))
// No backup because we got nothing to backup
return true;
return false;
}
bool CZNC::WriteConfig() {
CFile File(GetConfigFile());
if (!BackupConfig()) {
return false;
}