refs #151, stop throwing on fs:🇩🇪:refresh for broken symlinks, and added test

This commit is contained in:
Steffen Schuemann 2023-03-04 09:59:16 +01:00
parent a7a6d930fb
commit 6a94e84da4
2 changed files with 11 additions and 1 deletions

View File

@ -5273,7 +5273,7 @@ GHC_INLINE void directory_entry::refresh()
{
std::error_code ec;
refresh(ec);
if (ec) {
if (ec && (_status.type() == file_type::none || _symlink_status.type() != file_type::symlink)) {
throw filesystem_error(detail::systemErrorText(ec.value()), _path, ec);
}
}

View File

@ -1386,6 +1386,16 @@ TEST_CASE("fs.dir.entry - class directory_entry", "[filesystem][directory_entry]
CHECK(!(d2 != d2));
CHECK(d1 == d1);
CHECK(!(d1 == d2));
if(is_symlink_creation_supported()) {
fs::create_symlink(t.path() / "nonexistent", t.path() / "broken");
for (auto d3 : fs::directory_iterator(t.path())) {
CHECK_NOTHROW(d3.symlink_status());
CHECK_NOTHROW(d3.status());
CHECK_NOTHROW(d3.refresh());
}
fs::directory_entry entry(t.path() / "broken");
CHECK_NOTHROW(entry.refresh());
}
}
TEST_CASE("fs.class.directory_iterator - class directory_iterator", "[filesystem][directory_iterator][fs.class.directory_iterator]")