mirror of
https://github.com/Icinga/icinga2.git
synced 2026-02-19 02:29:16 -05:00
Merge 2e5342811a into 333534096e
This commit is contained in:
commit
990938c2cd
4 changed files with 16 additions and 2 deletions
|
|
@ -465,7 +465,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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -723,6 +723,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.
|
||||
|
|
|
|||
|
|
@ -120,6 +120,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);
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,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 a new issue