From bff969f40449e5a2b1ef2e01d7d1a6a35ac0d931 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 31 Mar 2011 18:15:49 +0200 Subject: [PATCH] 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 --- znc.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/znc.cpp b/znc.cpp index 346a1c65..c8616f9f 100644 --- a/znc.cpp +++ b/znc.cpp @@ -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);