mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 06:05:01 +02:00
Merge pull request #8157 from Icinga/bugfix/temporary-files-5124
Clean up temp files
This commit is contained in:
commit
f12666c166
@ -468,8 +468,14 @@ void ConfigObject::DumpObjects(const String& filename, int attributeTypes)
|
|||||||
Log(LogInformation, "ConfigObject")
|
Log(LogInformation, "ConfigObject")
|
||||||
<< "Dumping program state to file '" << filename << "'";
|
<< "Dumping program state to file '" << filename << "'";
|
||||||
|
|
||||||
|
try {
|
||||||
|
Utility::Glob(filename + ".tmp.*", &Utility::Remove, GlobFile);
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
Log(LogWarning, "ConfigObject") << DiagnosticInformation(ex);
|
||||||
|
}
|
||||||
|
|
||||||
std::fstream fp;
|
std::fstream fp;
|
||||||
String tempFilename = Utility::CreateTempFile(filename + ".XXXXXX", 0600, fp);
|
String tempFilename = Utility::CreateTempFile(filename + ".tmp.XXXXXX", 0600, fp);
|
||||||
fp.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
fp.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "config/configcompiler.hpp"
|
#include "config/configcompiler.hpp"
|
||||||
#include "base/configwriter.hpp"
|
#include "base/configwriter.hpp"
|
||||||
#include "base/configtype.hpp"
|
#include "base/configtype.hpp"
|
||||||
|
#include "base/exception.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
#include "base/objectlock.hpp"
|
#include "base/objectlock.hpp"
|
||||||
#include "base/convert.hpp"
|
#include "base/convert.hpp"
|
||||||
@ -163,8 +164,14 @@ void IcingaApplication::DumpModifiedAttributes()
|
|||||||
{
|
{
|
||||||
String path = Configuration::ModAttrPath;
|
String path = Configuration::ModAttrPath;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Utility::Glob(path + ".tmp.*", &Utility::Remove, GlobFile);
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
Log(LogWarning, "IcingaApplication") << DiagnosticInformation(ex);
|
||||||
|
}
|
||||||
|
|
||||||
std::fstream fp;
|
std::fstream fp;
|
||||||
String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0644, fp);
|
String tempFilename = Utility::CreateTempFile(path + ".tmp.XXXXXX", 0644, fp);
|
||||||
fp.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
fp.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
||||||
|
|
||||||
ConfigObject::Ptr previousObject;
|
ConfigObject::Ptr previousObject;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user