Skip to content

Commit

Permalink
Fix crash for Device not found (#51)
Browse files Browse the repository at this point in the history
```
The "Robocopy" task could not be instantiated from "C:\.nuget\packages\microsoft.build.artifacts\6.1.30\build\netstandard2.0\Microsoft.Build.Artifacts.dll".  System.TypeInitializationException: The type initializer for 'Microsoft.Build.Artifacts.FileSystem' threw an exception. ---> System.ComponentModel.Win32Exception: Failed retrieving volume information for A:\ with winerror 55
   at Microsoft.CopyOnWrite.Windows.NativeMethods.ThrowSpecificIoException(Int32 lastErr, String message) in D:\CoW\lib\Windows\NativeMethods.cs:line 30
   at Microsoft.CopyOnWrite.Windows.VolumeInfoCache.GetVolumeInfo(VolumePaths volumePaths) in D:\CoW\lib\Windows\VolumeInfoCache.cs:line 161
   at Microsoft.CopyOnWrite.Windows.VolumeInfoCache.BuildFromCurrentFilesystem() in D:\CoW\lib\Windows\VolumeInfoCache.cs:line 36
   at Microsoft.CopyOnWrite.CopyOnWriteFilesystemFactory.Create() in D:\CoW\lib\CopyOnWriteFilesystemFactory.cs:line 48
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Build.Artifacts.FileSystem..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Build.Artifacts.Tasks.Robocopy..ctor()
```
  • Loading branch information
stan-sz authored Oct 14, 2024
1 parent 945d316 commit d672703
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PropertyGroup>

<!-- DOCSYNC: When changing version number update README.md -->
<Version>0.3.11.0</Version>
<Version>0.3.12.0</Version>
<AssemblyVersion>0.9.9999.0</AssemblyVersion>

<Company>Microsoft</Company>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ File clones on Windows do not actually allocate space on-drive for the clone. Th

[![NuGet version (CopyOnWrite)](https://img.shields.io/nuget/v/CopyOnWrite?style=plastic)](https://www.nuget.org/packages/CopyOnWrite)

* 0.3.12 October 2024: Add ERROR_DEV_NOT_EXIST handling on getting free disk space
* 0.3.11 September 2024: Add ERROR_DEV_NOT_EXIST handling on volume enumeration
* 0.3.10 September 2024: Add ERROR_NO_SUCH_DEVICE handling on volume enumeration
* 0.3.9 September 2024: Fix https://github.com/microsoft/CopyOnWrite/issues/44 - follow up on ignoring FILE_NOT_FOUND on volume enumeration
Expand Down
7 changes: 6 additions & 1 deletion lib/Windows/VolumeInfoCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public VolumeInfo GetVolumeForPath(string path)
if (!result)
{
int lastErr = Marshal.GetLastWin32Error();
if (lastErr == NativeMethods.ERROR_DEV_NOT_EXIST)
{
return null;
}

NativeMethods.ThrowSpecificIoException(lastErr,
$"Failed retrieving drive volume cluster layout information for {volumePaths.PrimaryDriveRootPath} with winerror {lastErr}");
}
Expand All @@ -173,4 +178,4 @@ private static int IndexFromDriveLetter(char driveLetter)

return index;
}
}
}

0 comments on commit d672703

Please sign in to comment.