Skip to content

Add/use createDirectoriesIfAbsent method, robust against concurrent calls#8667

Merged
davidrohr merged 2 commits intoAliceO2Group:devfrom
shahor02:pr_mkdir
Apr 27, 2022
Merged

Add/use createDirectoriesIfAbsent method, robust against concurrent calls#8667
davidrohr merged 2 commits intoAliceO2Group:devfrom
shahor02:pr_mkdir

Conversation

@shahor02
Copy link
Collaborator

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shahor02, I would simplify this as:

std::filesystem::create_directories(path);
if (!std::filesystem::is_directory(path)) {
    throw std::runtime_error(fmt::format("Failed to create {} directory", path));
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, indeed, I see that it is not throwing on the existing directory! Changed to even shorter

if (!std::filesystem::create_directories(path) && !std::filesystem::is_directory(path)) {
   throw std::runtime_error(fmt::format("Failed to create {} directory", path));
}

@davidrohr davidrohr merged commit aad185e into AliceO2Group:dev Apr 27, 2022
@shahor02 shahor02 deleted the pr_mkdir branch April 27, 2022 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants