GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix unblock read only file by iSazonov · Pull Request #4395 · PowerShell/PowerShell

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Jul 31, 2017 •
edited by TravisEz13
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Adds a new non-terminating error

Fix #4390.

Problem

If a file is read only it is skipping silently.

Fix

Analize GetLastError() and throw if a file stream hasn't been removed.

First commit only refactor tests to use ShouldBeErrorId.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Ilya (iSazonov) added 3 commits July 31, 2017 09:28
@iSazonov
Refactor tests to use ShouldBeErrorId
16daa02
@iSazonov
Add throw if we can not remove a file stream
0215e2f
@iSazonov
Add new test
01bf444
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-already-signed label Jul 31, 2017
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Aug 1, 2017

Copy link
Copy Markdown
Member

Ilya (@iSazonov) what is the error message the user sees now?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Aug 2, 2017

Copy link
Copy Markdown
Collaborator Author

MSDN says that GetLastError can return either "Access denied" or "File not found".

Unblock-File : Access is denied
At line:1 char:1
+ Unblock-File -Path $Testpath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Unblock-File], Win32Exception
    + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.UnblockFileCommand
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SteveL-MSFT
Steve Lee (SteveL-MSFT) previously approved these changes Aug 2, 2017
View reviewed changes

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

Copy link
Copy Markdown
Member

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.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lzybkr
Jason Shirk (lzybkr) reviewed Aug 5, 2017
View reviewed changes
Comment thread src/System.Management.Automation/namespaces/FileSystemProvider.cs
if (!NativeMethods.DeleteFile(resultPath))
{
int error = Marshal.GetLastWin32Error();
throw new Win32Exception(error);

@lzybkr Jason Shirk (lzybkr) Aug 5, 2017

Copy link
Copy Markdown
Contributor

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.

Shouldn't this be a non-terminating error? The following should behave similarly:

dir | Unblock-File
dir | Remove-Item

In the Remove-Item case, a read only file reports an error, but all other files are deleted.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@iSazonov Ilya (iSazonov) Aug 5, 2017

Copy link
Copy Markdown
Collaborator Author

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.

Good catch!
AlternateDataStreamUtilities uses the pattern. So maybe add try-catch in Unblock-File cmdlet file?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@TravisEz13 Travis Plunk (TravisEz13) self-assigned this Aug 5, 2017
@iSazonov
Write non-terminating error
7461f79
@iSazonov

Ilya (iSazonov) commented Aug 11, 2017

Copy link
Copy Markdown
Collaborator Author

Jason Shirk (@lzybkr) Steve Lee (@SteveL-MSFT) Please continue the code review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13
Travis Plunk (TravisEz13) dismissed Steve Lee (SteveL-MSFT)’s stale review August 11, 2017 17:27

A commit has been added to the review

lzybkr
Jason Shirk (lzybkr) approved these changes Aug 11, 2017
View reviewed changes

@lzybkr Jason Shirk (lzybkr) left a comment

Copy link
Copy Markdown
Contributor

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.

Make sure the final commit message points out this is a new non-terminating error.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
SteveL-MSFT
Steve Lee (SteveL-MSFT) approved these changes Aug 14, 2017
View reviewed changes
@TravisEz13
Travis Plunk (TravisEz13) merged commit 813e4a6 into PowerShell:master Aug 14, 2017
@iSazonov
Ilya (iSazonov) deleted the fix-unblock-file-ro branch August 15, 2017 09:22
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@iSazonov @TravisEz13
Fix unblock read only file (PowerShell#4395)
b9e59d2
Adds a new non-terminating error when a file is read-only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@SteveL-MSFT Steve Lee (SteveL-MSFT) SteveL-MSFT approved these changes
+1 more reviewer
@lzybkr Jason Shirk (lzybkr) lzybkr approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@TravisEz13 Travis Plunk (TravisEz13)

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@iSazonov @SteveL-MSFT @lzybkr @msftclas @TravisEz13
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.