This commit is contained in:
2024-10-17 13:35:00 -05:00
parent da5752e971
commit a23adf6db6
2 changed files with 9 additions and 17 deletions

View File

@@ -397,18 +397,14 @@ auto file::sha256() -> std::optional<std::string> {
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
auto file::remove() -> bool {
if (not exists()) {
return true;
}
close();
return utils::retry_action([this]() -> bool {
#if defined(_WIN32)
return ::DeleteFileA(path_.c_str()) != 0;
return not exists() || (::DeleteFileA(path_.c_str()) != 0);
#else // !defined(_WIN32)
std::error_code ec{};
return std::filesystem::remove(path_, ec);
return not exists() || std::filesystem::remove(path_, ec);
#endif // defined(_WIN32)
});
}