Skip to content

Fix progress bar stacking when removing items#27675

Open
kborowinski wants to merge 1 commit into
PowerShell:masterfrom
kborowinski:fix-progress-remove-item
Open

Fix progress bar stacking when removing items#27675
kborowinski wants to merge 1 commit into
PowerShell:masterfrom
kborowinski:fix-progress-remove-item

Conversation

@kborowinski

Copy link
Copy Markdown
Contributor

PR Summary

Fixes the Remove-Item progress bar stacking issue when the number of removed files exceeds the initially calculated total.

The file count is calculated concurrently with file removal. Because of this race, _removedFiles can advance beyond _totalFiles. Requiring both values to be exactly equal prevents the completed progress record from being emitted, leaving the progress bar visible and causing subsequent progress records to stack.

This change completes the progress activity when _removedFiles is greater than or equal to _totalFiles.

This PR only fixes the progress bar stacking issue. The total file calculation can still be off by one and is not addressed by this change.

Fixes progress bar stacking only in #23875.

PR Context

Remove-Item can report more removed files than the calculated total, for example, Removed 11 of 10 files. In this situation, the existing equality check is never satisfied, so the progress activity remains active after the removal operation completes.

Using >= ensures that the progress record is completed even when concurrent file counting and removal cause the removed-file count to exceed the calculated total. This prevents stale Remove-Item progress bars from remaining visible and stacking with later progress output.

The underlying off-by-one issue in the total calculation remains and should be addressed separately.

PR Checklist

Copilot AI review requested due to automatic review settings July 11, 2026 15:46
@kborowinski
kborowinski requested a review from a team as a code owner July 11, 2026 15:46
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts Remove-Item progress completion logic in FileSystemProvider to prevent stale progress activities (and stacked progress bars) when concurrent total-file counting lags behind removal and the removed count surpasses the initially computed total.

Changes:

  • Updates the completion condition for the Remove-Item progress activity from == to >= so completion is emitted even when _removedFiles exceeds _totalFiles.

}

if (Stopping || _removedFiles == _totalFiles)
if (Stopping || _removedFiles >= _totalFiles)
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.

2 participants