Skip to content

Conversation

@jborean93
Copy link
Collaborator

PR Summary

Fix the percentage completion calculation for Remove-Item when deleting a directory or file that have no size. As the size calculation is done in a background thread this may or may not happen due to a race condition of when it is calculated.

PR Context

Fixes: #23868

I can't write a test for this as the _totalFiles and _totalBytes calculation is done in a background thread and will most likely run after the progress check is done in the main thread. The changes are consistent in what is done in #19038 for a similar problem.

PR Checklist

@jborean93 jborean93 requested a review from anmenaga as a code owner May 29, 2024 10:58
@iSazonov
Copy link
Collaborator

As for new test, we could create new test hook - if the hook is on we save Task.Run() in the test hook and wait the task later in remove item code. This makes the code sync

@jborean93
Copy link
Collaborator Author

I have reservations about tests that alter behavior during execution. This approach can lead to discrepancies, as seen in this issue, where the behavior observed during testing differs from that in the released package. Additionally, it increases the complexity of the code. I will defer to the Working Group on this matter and leave the decision, and work if they want it, to them.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Jun 10, 2024
@daxian-dbw daxian-dbw added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log and removed Review - Needed The PR is being reviewed labels Jul 1, 2024
Fix the percentage completion calculation for Remove-Item when deleting
a directory or file that have no size. As the size calculation is done
in a background thread this may or may not happen due to a race
condition of when it is calculated.
@daxian-dbw daxian-dbw merged commit 720f145 into PowerShell:master Jul 1, 2024
@microsoft-github-policy-service
Copy link
Contributor

microsoft-github-policy-service bot commented Jul 1, 2024

📣 Hey @jborean93, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

@jborean93 jborean93 deleted the remove-progress branch July 2, 2024 05:42
chrisdent-de pushed a commit to chrisdent-de/PowerShell that referenced this pull request Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove-Item throws "Attempted to divide by zero" on PS 7.5.0-preview.3

5 participants