mirror of
https://github.com/znc/znc.git
synced 2026-08-10 19:02:51 +02:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ public:
|
||||
const CString& GetHomePath() const { if (!CFile::Exists(m_sHomePath)) { CUtils::MakeDir(m_sHomePath); } return m_sHomePath; }
|
||||
const CString& GetZNCPath() const { if (!CFile::Exists(m_sZNCPath)) { CUtils::MakeDir(m_sZNCPath); } return m_sZNCPath; }
|
||||
const CString& GetConfPath() const { if (!CFile::Exists(m_sConfPath)) { CUtils::MakeDir(m_sConfPath); } return m_sConfPath; }
|
||||
const CString& GetConfBackupPath() const { if (!CFile::Exists(m_sConfBackupPath)) { CUtils::MakeDir(m_sConfBackupPath); } return m_sConfBackupPath; }
|
||||
const CString& GetUserPath() const { if (!CFile::Exists(m_sUserPath)) { CUtils::MakeDir(m_sUserPath); } return m_sUserPath; }
|
||||
CString GetPemLocation() const { return GetZNCPath() + "/znc.pem"; }
|
||||
const CString& GetConfigFile() const { return m_sConfigFile; }
|
||||
@@ -179,6 +178,8 @@ private:
|
||||
bool DoRehash(CString& sError);
|
||||
// Returns true if something was done
|
||||
bool HandleUserDeletion();
|
||||
// Backup znc.conf
|
||||
bool BackupConfig() const;
|
||||
|
||||
protected:
|
||||
bool m_bNeedRehash;
|
||||
@@ -192,7 +193,6 @@ protected:
|
||||
CString m_sHomePath;
|
||||
CString m_sZNCPath;
|
||||
CString m_sConfPath;
|
||||
CString m_sConfBackupPath;
|
||||
CString m_sUserPath;
|
||||
|
||||
CString m_sConfigFile;
|
||||
|
||||
Reference in New Issue
Block a user