GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — Fix `Move-Item` for FileSystemProvider to use copy-delete instead of move for DFS paths by SteveL-MSFT · Pull Request #14913 · PowerShell/PowerShell Conversation
|
|
Going to change this to try Move() first, then if AccessDenied, then try CopyDelete(). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Making this a draft PR for now, the customer tried a private and still had initial problem after latest change. Trying to determine if they got a different HResult. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looking Directory.MoveTo() implementation https://github.com/dotnet/runtime/blob/79ae74f5ca5c8a6fe3a48935e85bd7374959c570/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs#L119-L137 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) Looks like there can be different HResult for DFS, so can't rely on that. Based on https://github.com/dotnet/runtime/blob/79ae74f5ca5c8a6fe3a48935e85bd7374959c570/src/libraries/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs#L133, I think we can just try copydelete on an IOException. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
If we look GetExceptionForWin32Error()
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) I see, that makes sense, will update. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Need to think about this some more, the FQErrorID is now different on Linux vs Windows which is not acceptable. Maybe I can find out if there is a limited set of HResult we can check against. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
We already discussed this with Rob Holt (@rjmholt) . See https://github.com/PowerShell/PowerShell/pull/13044/files#r446770600 I guess .Net unify the behavior (exceptions) and we can have one code path for all platforms. I see the test
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…nied for Windows to use CopyAndDelete()
|
Ilya (@iSazonov) can you be specific on your concerns about that test? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I'd expect And I guess .Net team unified exceptions in the API for all platforms and we could have one code path here. Both return codes fall in IOException and we need only to ignore FileNotFoundException, DirectoryNotFoundException, PathTooLongException. We must take into account that there are many ways to mount a different file system / volume and they may have different return codes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) so that test case relies on a testhook to simulate doing a move across devices/volumes. It succeeds because the test hook forces it to throw the exception that results in CopyAndDelete() to be used. In one of my commits, I tried the approach of ignoring FileNotFoundException, DirectoryNotFoundException, PathTooLongException but that resulted in another FullyQualifiedErrorId to change whereas the current implementation checking for specific HResult which is specific to the Unix error of moving across devices and Windows error of moving across volumes has less impact. I was also concerned that other specific IOExceptions beyond those ignored types would fallback to CopyAndDelete() when it didn't in the past and might cause unintended side effects. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, my bad. With
We had similar discussion in #13634 (comment) My proposal: private void MoveDirectoryInfoUnchecked(DirectoryInfo directory, string destinationPath, bool force) { try { if (InternalTestHooks.ThrowExdevErrorOnMoveDirectory) { throw new IOException("Invalid cross-device link", hresult: TEST_CODE); } directory.MoveTo(destinationPath); } catch (Exception exception) { switch (exception) { case FileNotFoundException: case DirectoryNotFoundException: case PathTooLongException: throw; case IOException: CopyAndDelete(directory, destinationPath, force); break; default: throw; } } } |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
the current implementation checking for specific HResult which is specific to the Unix error of moving across devices and Windows error of moving across volumes has less impact. I was also concerned that other specific IOExceptions beyond those ignored types would fallback to CopyAndDelete() when it didn't in the past and might cause unintended side effects.
I agree with this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🎉 Handy links: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…move for DFS paths (PowerShell#14913)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.