CZNC::WriteNewConfig() check for errors

This code now errors out if there is any error while writing the config. I
tested this with a full file system (full tmpfs of size 4k).

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2011-03-31 18:15:49 +02:00
parent cc2d84d4a6
commit bff969f404
+14 -1
View File
@@ -859,11 +859,24 @@ bool CZNC::WriteNewConfig(const CString& sConfigFile) {
if (bFileOpen) {
File.Close();
CUtils::PrintStatus(true);
if (File.HadError())
CUtils::PrintStatus(false, "There was an error while writing the config");
else
CUtils::PrintStatus(true);
} else {
cout << endl << "----------------------------------------------------------------------------" << endl << endl;
}
if (File.HadError()) {
bFileOpen = false;
CUtils::PrintMessage("Printing the new config to stdout instead:");
cout << endl << "----------------------------------------------------------------------------" << endl << endl;
for (unsigned int a = 0; a < vsLines.size(); a++) {
cout << vsLines[a] << endl;
}
cout << endl << "----------------------------------------------------------------------------" << endl << endl;
}
const CString sProtocol(sSSL.empty() ? "http" : "https");
CUtils::PrintMessage("");
CUtils::PrintMessage("To connect to this ZNC you need to connect to it as your IRC server", true);