Skip to content

Commit

Permalink
Merge pull request #2234 from joto/remove-file
Browse files Browse the repository at this point in the history
Remove flat node file using std::filesystem::remove()
  • Loading branch information
lonvia authored Aug 19, 2024
2 parents 1e2a1f2 + b328d3b commit 0908fd5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/node-persistent-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
* For a full list of authors see the git log.
*/

#include "logging.hpp"
#include "node-persistent-cache.hpp"

#include "logging.hpp"

#include <cassert>
#include <cerrno>
#include <filesystem>
#include <system_error>
#include <utility>

Expand Down Expand Up @@ -55,9 +57,14 @@ node_persistent_cache::~node_persistent_cache() noexcept
if (m_remove_file) {
try {
log_debug("Removing persistent node cache at '{}'.", m_file_name);
std::error_code ec{};
std::filesystem::remove(m_file_name, ec);
if (ec) {
log_warn("Failed to remove persistent node cache at '{}': {}.",
m_file_name, ec.message());
}
} catch (...) {
// exception ignored on purpose
}
unlink(m_file_name.c_str());
}
}

0 comments on commit 0908fd5

Please sign in to comment.