Skip to content

Catch IOException in Get-FileHash - #11944

Merged
Dongbo Wang (daxian-dbw) merged 6 commits into
PowerShell:masterfrom
iSazonov:catch-ioexc-getfilehash
Mar 13, 2020
Merged

Dongbo Wang (daxian-dbw) merged 6 commits into
PowerShell:masterfrom
iSazonov:catch-ioexc-getfilehash

Conversation

@iSazonov

Copy link
Copy Markdown
Collaborator

PR Summary

Fix #11931
Catch all IO exceptions in Get-FileHash cmdlet to do not terminate pipeline.

PR Context

PR Checklist

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Feb 24, 2020
@iSazonov Ilya (iSazonov) added this to the 7.1.0-preview.1 milestone Feb 24, 2020

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.

This should be WriteError() too - as in the original WinPS implementation, any exception for a given pipeline input should be a non-terminating error.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, It is was copy-past without fix.

@iSazonov
Ilya (iSazonov) force-pushed the catch-ioexc-getfilehash branch from ef07923 to 9fa6d77 Compare March 9, 2020 17:27

@daxian-dbw Dongbo Wang (daxian-dbw) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ilya (@iSazonov) You can use the special .sys file on the system drive of a windows OS for the test, for example, pagefile.sys or swapfile.sys.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Dongbo Wang (@daxian-dbw) I added new test.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Oh, It turns out CI Windows VM redirect pagefile.sys so I have to use WMI to find it in the new test.

@daxian-dbw

Copy link
Copy Markdown
Member

Didn't know you can use cim cmdlet for that, very cool :)
LGTM.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 10e7d19 into PowerShell:master Mar 13, 2020
@iSazonov
Ilya (iSazonov) deleted the catch-ioexc-getfilehash branch March 13, 2020 16:26
@ghost

Copy link
Copy Markdown

🎉v7.1.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
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.

Get-FileHash Terminates at Corrupt File

5 participants