From 8adffa8c9a9536258b49a5da481e9d6d0fa2eab1 Mon Sep 17 00:00:00 2001 From: stan-sz <37585349+stan-sz@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:19:47 +0200 Subject: [PATCH 1/4] Fix crash for Device not found 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() --- lib/Windows/VolumeInfoCache.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Windows/VolumeInfoCache.cs b/lib/Windows/VolumeInfoCache.cs index 432b480..06aff76 100644 --- a/lib/Windows/VolumeInfoCache.cs +++ b/lib/Windows/VolumeInfoCache.cs @@ -151,6 +151,11 @@ public VolumeInfo GetVolumeForPath(string path) out ulong _); if (!result) { + if (lastErr == NativeMethods.ERROR_DEV_NOT_EXIST) + { + return null; + } + int lastErr = Marshal.GetLastWin32Error(); NativeMethods.ThrowSpecificIoException(lastErr, $"Failed retrieving drive volume cluster layout information for {volumePaths.PrimaryDriveRootPath} with winerror {lastErr}"); @@ -173,4 +178,4 @@ private static int IndexFromDriveLetter(char driveLetter) return index; } -} \ No newline at end of file +} From 5d3f65fe87c8b58d74bf5a8f2b32b1b18649d7b8 Mon Sep 17 00:00:00 2001 From: stan-sz <37585349+stan-sz@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:21:08 +0200 Subject: [PATCH 2/4] Update Directory.Build.props --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 85a5424..786ea39 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,7 +26,7 @@ - 0.3.11.0 + 0.3.12.0 0.9.9999.0 Microsoft From b75f301805d97f07f2467cc72be45e750ed0f38a Mon Sep 17 00:00:00 2001 From: stan-sz <37585349+stan-sz@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:22:22 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fc445db..48ba29b 100644 --- a/README.md +++ b/README.md @@ -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 From 4bb1b64da0a26304d974f32ae42018fb4e100bf3 Mon Sep 17 00:00:00 2001 From: stan-sz <37585349+stan-sz@users.noreply.github.com> Date: Mon, 14 Oct 2024 13:57:46 +0200 Subject: [PATCH 4/4] Update VolumeInfoCache.cs --- lib/Windows/VolumeInfoCache.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Windows/VolumeInfoCache.cs b/lib/Windows/VolumeInfoCache.cs index 06aff76..c4125c8 100644 --- a/lib/Windows/VolumeInfoCache.cs +++ b/lib/Windows/VolumeInfoCache.cs @@ -151,12 +151,12 @@ public VolumeInfo GetVolumeForPath(string path) out ulong _); if (!result) { + int lastErr = Marshal.GetLastWin32Error(); if (lastErr == NativeMethods.ERROR_DEV_NOT_EXIST) { return null; } - int lastErr = Marshal.GetLastWin32Error(); NativeMethods.ThrowSpecificIoException(lastErr, $"Failed retrieving drive volume cluster layout information for {volumePaths.PrimaryDriveRootPath} with winerror {lastErr}"); }