Skip to content

Conversation

@bc-lee
Copy link

@bc-lee bc-lee commented Oct 24, 2025

This commit introduces two new options, LRO_METALINK_EXCLUDE_DOMAIN and LRO_METALINK_EXCLUDE_LOCATION, to the LrHandle structure. These options allow users to specify lists of domains and locations to exclude during metalink processing.

Related: rpm-software-management/dnf5#1483

This commit introduces two new options, LRO_METALINK_EXCLUDE_DOMAIN and
LRO_METALINK_EXCLUDE_LOCATION, to the LrHandle structure.
These options allow users to specify lists of domains and locations
to exclude during metalink processing.
@bc-lee bc-lee requested a review from a team as a code owner October 24, 2025 11:58
@bc-lee bc-lee requested review from ppisar and removed request for a team October 24, 2025 11:58
Copy link
Contributor

@ppisar ppisar left a comment

Choose a reason for hiding this comment

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

While I welcome this feature, I think the interface (a scalar regular expression, not breaking ABI) and implementation (validate early) could be better.

LRO_PASSWORD, /*!< (char *)
Password for HTTP authentication */

LRO_METALINK_EXCLUDE_DOMAIN, /*!< (char ** NULL-terminated)
Copy link
Contributor

Choose a reason for hiding this comment

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

This enhances API. You need to increase a minor version of librepo in VERSION.cmake.

Password for HTTP authentication */

LRO_METALINK_EXCLUDE_DOMAIN, /*!< (char ** NULL-terminated)
List of domains to exclude from metalink */
Copy link
Contributor

Choose a reason for hiding this comment

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

Also please append to the documentation since which version is this option available.

}
} else {
// Invalid regex, treat as literal string
g_warning("%s: Invalid regex for metalink location exclusion \"%s\": %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please spell "regex" in full as "regular expression". This is not Perl.


gboolean
lr_metalink_parse_file(LrMetalink *metalink,
LrHandle *handle,
Copy link
Contributor

Choose a reason for hiding this comment

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

lr_metalink_parse_file() is public functio. This breaks API and ABI. I think we need to wind a different way of passing the exclusion options. If there is not context or object to store the options to, I recommend adding a new function and making this old as a single wrapper around it.

.. data:: LRO_METALINK_EXCLUDE_DOMAIN
*List of strings*. List of regex patterns to exclude domains from metalink.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it a list? If it is a regular expression, then string is enough.
What kind of regular expression it it? That needs to be documented.

for (int i = 0; pd->handle->metalink_exclude_location[i]; i++) {
const char *pattern = pd->handle->metalink_exclude_location[i];
GError *regex_err = NULL;
GRegex *regex = g_regex_new(pattern,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you compile and validate the expression here deep in the XML parser? Best place is in lr_handle_setopt().

@ppisar ppisar self-assigned this Oct 27, 2025
@bc-lee
Copy link
Author

bc-lee commented Oct 30, 2025

Thanks for the review. I think I need to redesign the API to reduce API/ABI incompatibilities. It will take a few days, so I’ll mark this PR as a draft for now.

@bc-lee bc-lee marked this pull request as draft October 30, 2025 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants