Skip to content

Commit

Permalink
Check that the server root directory exists before creating an iterat…
Browse files Browse the repository at this point in the history
…or to it

There is some room for race condition between this check and iterator creation,
but don't consider it a problem.
  • Loading branch information
deniskovalchuk committed Aug 4, 2023
1 parent cb5f9cb commit 5c7f3f2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/ftp/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ class client : public testing::Test

void TearDown() override
{
// TODO: The server_root_dir_ may not exist.
/* Clean up the server root directory after each test. */
for (const std::filesystem::directory_entry & path : std::filesystem::directory_iterator(server_root_dir_))
if (std::filesystem::exists(server_root_dir_))
{
std::filesystem::remove_all(path);
for (const std::filesystem::directory_entry & path : std::filesystem::directory_iterator(server_root_dir_))
{
std::filesystem::remove_all(path);
}
}
}

Expand Down

0 comments on commit 5c7f3f2

Please sign in to comment.