`CopyOnWriteLinkSupportedBetweenPaths` throws for a source on a mapped network drive

Open Beginner friendly
#60 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp

Research direction

Start with WindowsCopyOnWriteFilesystem.cs, especially CopyOnWriteLinkSupportedBetweenPaths, and read VolumeInfoCache.cs around GetVolumeForPath. Reproduce the call with a file on a mapped Q: drive; done means the method returns false instead of throwing when no known volume exists.

Written by the indexing model from the issue text.

Description

The XML documentation of ICopyOnWriteFilesystem.CopyOnWriteLinkSupportedBetweenPaths says:

Determines whether a copy-on-write link can be created between the provided paths.

Returns: True if a link can be created, false if it cannot.

A mapped network drive does not support a link. The expected result is therefore false, not an exception. However, the method throws:

System.ArgumentException: No known volume information for 'Q:\share\big-installer.zip'. If the drive was added recently you may need to recreate the filesystem cache.
   at Microsoft.CopyOnWrite.Windows.VolumeInfoCache.GetVolumeForPath(String path) in D:\CoW\lib\Windows\VolumeInfoCache.cs:line 102
   at Microsoft.CopyOnWrite.Windows.WindowsCopyOnWriteFilesystem.CopyOnWriteLinkSupportedBetweenPaths(String source, String destination, Boolean pathsAreFullyResolved) in D:\CoW\lib\Windows\WindowsCopyOnWriteFilesystem.cs:line 46

Q: is a mapped network drive. VolumeInfoCache holds the local volumes only, so GetVolumeForPath finds no volume for the path and throws.

Steps to reproduce

  1. Map a network share to a drive letter, for example Q:.
  2. Put a file on that share.
  3. Call CopyOnWriteLinkSupportedBetweenPaths with the file on Q: as the source.

Result: the call throws ArgumentException.
Expected: the call returns false.

Suggested fix

Return false for a path with no known volume, in the same way that the volume enumeration ignores a volume that gives an error. The release history shows this pattern for other volume errors:

  • 0.3.7: ignore ACCESS_DENIED on volume enumeration.
  • 0.3.9 to 0.3.12: ignore FILE_NOT_FOUND, ERROR_NO_SUCH_DEVICE, and
    ERROR_DEV_NOT_EXIST on volume enumeration.
  • 0.4.2: ignore any volume that gives an error.

A mapped network drive is arguably the next case in this series.

Version

  • CopyOnWrite 0.5.0 (NuGet)
  • .NET 8, Windows 11
Dominant language
C#
Stars
153
Forks
9
Avg merge
10d 21h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/CopyOnWrite

All issues in microsoft/CopyOnWrite

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.