## Fix Duplicate Package Notifications

### Key Fix:
- **Eliminate Duplicates**: Each package now appears once regardless of host configurations
- **Base Name Tracking**: Use `processed_packages` set to track unique packages by base name
- **Clean Logic**: Check `app_base_name not in processed_packages` instead of full package name

### Problem Solved:
Before: Same package appeared multiple times for different host configurations
```
comi-parsec : 150.99.0.0-1 from : 150.93.2.0-2
comi-parsec : 150.99.0.0-1 from : 150.93.2.0-2
comi-parsec : 150.99.0.0-1 from : 150.93.2.0-2
```

After: Each package appears once with correct version information
```
comi-parsec : 150.99.0.0-1 from : 150.93.2.0-2
comi-stormshield-vpn : 5.1.2-8 from : 5.1.1-7
```

### Technical Changes:
- Added `processed_packages = set()` for duplicate tracking
- Extract `app_base_name` once for cleaner code
- Mark packages as processed with `processed_packages.add(app_base_name)`

### Version Bump:
Updated to version 2-2 for this bug fix
This commit is contained in:
2025-12-30 16:19:49 +01:00
parent 388320bbaf
commit 0cc88a0eb9
2 changed files with 14 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
package : comi-apps-to-update-on-wapt-server
version : 2-1
version : 2-2
architecture : all
section : base
priority : optional
@@ -29,7 +29,7 @@ editor :
keywords :
licence : opensource_free,wapt_public
homepage :
package_uuid : 8aa32575-7ddd-d66f-dce2-1f7363c259e3
package_uuid : ab4f77cb-2415-f2a2-d615-3794f84041a3
valid_from :
valid_until :
forced_install_on :
@@ -39,6 +39,6 @@ max_os_version :
icon_sha256sum : d642b35ce6441158dc071677fb958ad01830271d373c332d64e48dec67f80834
signer : pcosson_key
signer_fingerprint: a25582410cf03bad179a60c189f459a0b03821c92c0cedf209e82448a66a9b4e
signature_date : 2025-12-30T14:58:03.000000
signature_date : 2025-12-30T15:09:27.000000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
signature : RjghL24x4fj+OVYwHrYc9VRdp+on7V2GurFUS9E9ckLW8+c31EkINGJOtYQiqXlJRPxp7t91+P5sPHmLpX2SjUGThBvgIHDInLhYU22r+ZDGzUyMNwZGjGUyIv6tckGontcw3ysH3YtXRZbg7YID2GTk5zyoEv8BTDvj6BoYQiFMEF36F1yMOLu+S3/8/phUMe26YfbmLi48UbMN1gXvfhAhynl60p2KwYM4nH716IKQXSD3R4Sf4IjkrEjxauIjeG1p2ZQD+FavmCjRDJwrrUY8mWXW3RmNJPTmR1YeS68loWejx2SWfmTER0GdZq+FlHrC7iBg+msh6uVPqnLcag==
signature : TQFiZPpMiQEDexrKxDjos2azCOq/oqiJ7uEXr6eaN6VL1oLwsoDRi7kcep7EDQka2tDhdluaJJAVscaMaHe0JRXyGketu8lZr0R+bowpo/NXAlyFmjXsa58CihN70WWND+S00HtGYbfAfpQPxxB6yitoqEMeqNOdDxCOKlTeW0uYdORTZ5/Mf1T2CW4hRlXclZYzMeBrZjEYq4pFQCTT38KSEJ3HgPmat+Y5TN0mtUwnwGoZRD5URcwtVQG/1G5n9ZUPVNLpr+q7esdSZjIsYHcp06v+NZaVo0ma4+v/wj6yJphKLdT85A0KRbgKoHdT/+hXcNbA8T2/DEkzmc68bw==

View File

@@ -241,21 +241,27 @@ def _get_packages_versions(store, dict_host_capa):
def _compare_and_notify(local_package_list, online_package_list, dict_host_capa):
"""Compares local and online packages and sends notifications based on configuration."""
list_app_to_update = []
processed_packages = set() # Track already processed packages to avoid duplicates
for hc in dict_host_capa:
for app in local_package_list[hc]:
if "-" in app:
if "tis-" + app.split("-", 1)[1] in online_package_list[hc]:
if PackageVersion(local_package_list[hc][app]) < PackageVersion(online_package_list[hc]["tis-" + app.split("-", 1)[1]]) and app not in list_app_to_update:
app_base_name = app.split("-", 1)[1]
tis_app_name = "tis-" + app_base_name
if tis_app_name in online_package_list[hc]:
if PackageVersion(local_package_list[hc][app]) < PackageVersion(online_package_list[hc][tis_app_name]) and app_base_name not in processed_packages:
print(
f'{app} new version detected from {local_package_list[hc][app]} to {online_package_list[hc]["tis-"+app.split("-", 1)[1]]} for {hc}'
f'{app} new version detected from {local_package_list[hc][app]} to {online_package_list[hc][tis_app_name]} for {hc}'
)
list_app_to_update.append(
{
"package": app,
"old_version": local_package_list[hc][app],
"new_version": online_package_list[hc]["tis-" + app.split("-", 1)[1]],
"new_version": online_package_list[hc][tis_app_name],
}
)
processed_packages.add(app_base_name) # Mark as processed to avoid duplicates
WAPT.write_audit_data_if_changed("apps_to_upgrade", "list", list_app_to_update, max_count=3)
# Get notification configuration