Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes an outrageous number of bugs and warnings #90

Merged
merged 23 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/repos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ void RepoManager::commitStatus()

for (auto const& dir_entry :
std::filesystem::directory_iterator { tmpdir }) {
std::filesystem::copy(dir_entry, "/etc/yum.repos.d");
try {
std::filesystem::copy(dir_entry, "/etc/yum.repos.d");
} catch (std::filesystem::filesystem_error const& ex) {
if (ex.code().message().starts_with("File exists")) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

We must not compare string to handle errors. That's very bad design. Text can change, and the language of the glibc may also changes this. We need to aim for portability so a better implementation is to compare the error return code, like this:

if (ex.code().default_error_condition() == std::errc::file_exists) {
	continue;
}

// If it's not "file exists", maybe rethrow or handle differently
std::cerr << "Copy failed: " << ex.what() << '\n';
// handle or rethrow

continue;
}
}
}

std::vector<std::string> to_enable;
Expand Down
Loading