Skip to content

Don't write an error if file already unblocked - #5362

Merged
Ilya (iSazonov) merged 5 commits into
PowerShell:masterfrom
iSazonov:fix-error-in-unblock-file
Nov 10, 2017
Merged

Ilya (iSazonov) merged 5 commits into
PowerShell:masterfrom
iSazonov:fix-error-in-unblock-file

Conversation

@iSazonov

Copy link
Copy Markdown
Collaborator

Fix #5353

@lzybkr Jason Shirk (lzybkr) 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.

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)

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.

Jeffrey Snover (@jpsnover) suggests adding a verbose message here if the block stream is not found

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.

Done. I tried to avoid adding a resource string

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.

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.

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.

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)

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.

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>

Copy link
Copy Markdown
Collaborator

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?

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.

The file is already unblocked:

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.

Keith Hill (@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.

Mark Kraus (@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.

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.

Steve Lee (@SteveL-MSFT) You're right, and what Keith wrote is more accurate. but already not blocked sounds odd.. maybe The file is not blocked?

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.

Mark Kraus (@markekraus) agree, that sounds better: The file is not blocked.

@SteveL-MSFT Steve Lee (SteveL-MSFT) 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) can you make the requested string change?

@iSazonov

Ilya (iSazonov) commented Nov 10, 2017

Copy link
Copy Markdown
Collaborator Author

Yes, I agree.
Is it good (first part too):
"No 'Zone.Identifier' file stream. The file is not blocked: {0}"

@SteveL-MSFT

Copy link
Copy Markdown
Member

Ilya (@iSazonov) thinking about it, I think it may be better to exclude that implementation detail as it may confuse some users. I think just:

The file is not blocked: {0}

Is good.

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Done.

@iSazonov
Ilya (iSazonov) merged commit 5fd1b47 into PowerShell:master Nov 10, 2017
@iSazonov
Ilya (iSazonov) deleted the fix-error-in-unblock-file branch November 10, 2017 14:14
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants