Skip to content

Conversation

@Janek91
Copy link
Contributor

@Janek91 Janek91 commented Oct 10, 2025

  • I have read the contributing guidelines, and I agree with the Code of Conduct.
  • Have you checked that there aren't other open pull requests for the same changes?
  • Have you tested that the committed code can be executed without errors?
  • This PR is not composed of garbage changes used to farm GitHub activity to enter potential Crypto AirDrops.
    Any user suspected of farming GitHub activity with crypto purposes will get banned. Submitting broken code wastes the contributors' time, who have to spend their free time reviewing, fixing, and testing code that does not even compile breaks other features, or does not introduce any useful changes. I appreciate your understanding.

Description

This PR adds duplicate detection logic to prevent the same package update operation from being queued multiple times during unattended updates.

Problem

When unattended auto-updates trigger while the user is away from their PC (particularly when UAC prompts are waiting for user interaction), the UpdateAll() method runs repeatedly and creates dozens of duplicate operations for the same package. This happens because:

  1. Auto-updates call UpdateAll() periodically (every 60 minutes on success, 10 minutes on failure)
  2. When UAC prompts are waiting, operations are created but package tags aren't set immediately
  3. The next UpdateAll() call doesn't detect the existing operation and creates duplicates
  4. Users return to find dozens of duplicate operations and UAC prompts to cancel

Solution

Added duplicate detection in the Update() method (src/UniGetUI/AppOperationHelper.cs) that:

  • Checks the operation list before creating a new UpdatePackageOperation
  • Uses GetHash() to compare packages by Manager, Source, and Package ID
  • Only checks operations with status InQueue or Running
  • Returns the existing operation if a duplicate is detected, preventing queue pollution
  • Logs an informational message when duplicates are skipped

Changes

  • Modified: src/UniGetUI/AppOperationHelper.cs - Added 14 lines of duplicate detection logic

Testing

  • ✅ Code compiles without errors
  • ✅ No linter errors introduced
  • ✅ Uses existing infrastructure (operation list and package hash comparison)
  • ✅ Minimal, focused change with clear logging

Expected Impact

After this fix:

  • Users will see only one update operation per package
  • Only one UAC prompt per package update
  • No more dozens of duplicate operations to cancel
  • Cleaner operation queue even when away during auto-updates

Closes #4131

Add duplicate detection logic to the Update() method to prevent the same package from being queued multiple times during unattended updates.

When auto-updates trigger repeatedly while UAC prompts are pending, the system now checks if an update operation for the package is already in queue or running before creating a new one. This prevents dozens of duplicate operations from accumulating.

Fixes marticliment#4131
Per maintainer feedback, the duplicate detection should only apply to automatic updates (UpdateAll and UpdateAllForManager), not manual user-initiated updates.

This allows users to manually retry updates while still preventing duplicate operations during unattended auto-updates.

Also fixed operator precedence issue in UpdateAllForManager condition.
Added 5 unit tests to verify the duplicate detection logic works correctly:

- Package.GetHash() returns same value for identical packages

- Package.GetHash() returns different values for different packages

- Package.GetHash() differs for same package from different managers

- Simulation test showing how multiple UpdateAll() calls are handled

Tests mock the UAC waiting scenario where operations remain in queue,

verifying that the duplicate detection prevents creating multiple

operations for the same package (Manager + Source + PackageID).
@Janek91 Janek91 force-pushed the fix/4131-duplicate-unattended-updates branch from 2aca226 to 3733638 Compare October 12, 2025 14:32
@Janek91
Copy link
Contributor Author

Janek91 commented Oct 12, 2025

Thanks for the feedback! You're absolutely right - I've moved the duplicate detection logic to only apply during automatic updates.
I've also added tests in UniGetUI.PackageEngine.Serializable.Tests that verify Package.GetHash() works correctly for duplicate detection
The duplicate detection now only triggers during unattended update scenarios (like the issue #4131 describes), while manual user actions remain unrestricted.

@Janek91 Janek91 requested a review from marticliment October 13, 2025 09:02
@marticliment marticliment merged commit 32f4789 into marticliment:main Oct 14, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unattended update attempts get duplicated

2 participants