wsd: faster jail directory cleanup

Around 1.5x faster than Poco,
which first enumerates files into
a container, then iterates over
them and stats before unlinking.

Here we enumerate and unlink in
a single pass.

Change-Id: I79d1c0f1b5ec557ccc4f0e2ec7a0609051d8d212
Reviewed-on: https://gerrit.libreoffice.org/33680
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian
2017-01-30 00:04:10 -05:00
committed by Ashod Nakashian
parent 65be8a3e56
commit 0d4d506ea3
2 changed files with 40 additions and 11 deletions

View File

@ -63,17 +63,7 @@ namespace FileUtil
/// Supresses exception when the file is already removed.
/// This can happen when there is a race (unavoidable) or when
/// we don't care to check before we remove (when no race exists).
inline void removeFile(const std::string& path, const bool recursive = false)
{
try
{
Poco::File(path).remove(recursive);
}
catch (const std::exception&)
{
// Already removed or we don't care about failures.
}
}
void removeFile(const std::string& path, const bool recursive = false);
inline void removeFile(const Poco::Path& path, const bool recursive = false)
{