-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Don't write an error if file already unblocked #5362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't write an error if file already unblocked #5362
Conversation
c6a244a to
668028b
Compare
lzybkr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see there are existing tests for "file does not exist" and they still pass, so this change looks good.
| WriteError(new ErrorRecord(accessException, "RemoveItemUnauthorizedAccessError", ErrorCategory.PermissionDenied, path)); | ||
| // NativeErrorCode=2 - File not found. | ||
| // If the block stream not found the 'path' was not blocked and we successfully return. | ||
| if (accessException.NativeErrorCode != 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpsnover suggests adding a verbose message here if the block stream is not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I tried to avoid adding a resource string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to add a resource string saying:
File '{0}' did not contain a 'Zone.Identifier' file stream and was already not blocked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a resouce string with {0} at last position - we should take into account long paths.
| WriteError(new ErrorRecord(accessException, "RemoveItemUnauthorizedAccessError", ErrorCategory.PermissionDenied, path)); | ||
| // NativeErrorCode=2 - File not found. | ||
| // If the block stream not found the 'path' was not blocked and we successfully return. | ||
| if (accessException.NativeErrorCode != 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to add a resource string saying:
File '{0}' did not contain a 'Zone.Identifier' file stream and was already not blocked.
| <value>'{0}' is not supported in this system.</value> | ||
| </data> | ||
| <data name="NoZoneIdentifierFileStream" xml:space="preserve"> | ||
| <value>"No 'Zone.Identifier' file stream. The file was already not blocked: {0}"</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be present tense e.g. "The file is already not blocked: ..."? Maybe ask one of your documentation folks about the wording for this error message? Sorry but error messages in PowerShell really need help and I'd rather we not contribute to the problem with poor error messages. Do you have a "doc/grammar" person to review error messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file is already unblocked:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rkeithhill unfortunately at this time, our previous doc person left Msft. Doc changes aren't breaking, so we can continue to improve them. I agree reading it again that it should probably be present tense: The file is already not blocked.
@markekraus perhaps I'm a bit pedantic on this one, but unblocked implies the file was once blocked which may not have been the case here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SteveL-MSFT You're right, and what Keith wrote is more accurate. but already not blocked sounds odd.. maybe The file is not blocked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markekraus agree, that sounds better: The file is not blocked.
SteveL-MSFT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iSazonov can you make the requested string change?
|
Yes, I agree. |
|
@iSazonov thinking about it, I think it may be better to exclude that implementation detail as it may confuse some users. I think just: Is good. |
|
Done. |
Fix #5353