## 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:
14
setup.py
14
setup.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user