-
Notifications
You must be signed in to change notification settings - Fork 97
Add support for excluding domains and locations in metalink parsing #357
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
base: master
Are you sure you want to change the base?
Conversation
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.
ppisar
left a comment
There was a problem hiding this 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) |
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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().
|
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. |
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