mirror of https://github.com/Icinga/icinga2.git
parent
aa4f53009e
commit
1f238724e4
|
@ -469,7 +469,7 @@ void ConfigObject::DumpObjects(const String& filename, int attributeTypes)
|
|||
<< "Dumping program state to file '" << filename << "'";
|
||||
|
||||
try {
|
||||
Utility::Glob(filename + ".tmp.*", &Utility::Remove, GlobFile);
|
||||
Utility::Glob(filename + ".tmp.*", &Utility::RemoveIfOld, GlobFile);
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "ConfigObject") << DiagnosticInformation(ex);
|
||||
}
|
||||
|
|
|
@ -719,6 +719,19 @@ void Utility::RemoveDirRecursive(const String& path)
|
|||
(void)fs::remove_all(fs::path(path.Begin(), path.End()));
|
||||
}
|
||||
|
||||
void Utility::RemoveIfOld(const String& path)
|
||||
{
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
fs::path p (path.Begin(), path.End());
|
||||
boost::system::error_code ec;
|
||||
auto modTime (fs::last_write_time(p, ec));
|
||||
|
||||
if (!ec && modTime < GetTime() - 24 * 60 * 60) {
|
||||
(void)fs::remove(p);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copies a source file to a target location.
|
||||
* Caller must ensure that the target's base directory exists and is writable.
|
||||
|
|
|
@ -116,6 +116,7 @@ public:
|
|||
|
||||
static void Remove(const String& path);
|
||||
static void RemoveDirRecursive(const String& path);
|
||||
static void RemoveIfOld(const String& path);
|
||||
static void CopyFile(const String& source, const String& target);
|
||||
static void RenameFile(const String& source, const String& target);
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ void IcingaApplication::DumpModifiedAttributes()
|
|||
String path = Configuration::ModAttrPath;
|
||||
|
||||
try {
|
||||
Utility::Glob(path + ".tmp.*", &Utility::Remove, GlobFile);
|
||||
Utility::Glob(path + ".tmp.*", &Utility::RemoveIfOld, GlobFile);
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "IcingaApplication") << DiagnosticInformation(ex);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue