Do not create duplicate udev attributes #825
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When editing an interface name.
If no previous udev rule exist and the udev rule to be written is based on the interface :mac, then it generates a duplicate attribute:
Something like:
That also happens with an existent rule and pressing 'OK' without modifying the key attribute.
In combination with this another bug the situation is even worworst because there could be two different mac addresses, the current and the permanent one.
Solution
When editing an interface name:
1.- The rule only will be updated if the matching attribute or value from the original differs.
2.- The update_item_udev_rule! method will check if a rule already exist and if not will initialize it. As the default rule is based on :mac, we will return after initialization in case the update rule is based on :mac.
Testing