Closed alexrp closed 7 months ago
I use it in a 2-OS repo daily. On Linux and Mac the CoW base library returns false
from the methods that ask whether CoW works between paths or in a directory tree. Which means on Linux and Mac that regular File.Copy
is used instead of a CoW link.
I've not started any work to add in the Linux and Mac clone calls in the base library. If you're interested in contributing I'd welcome the added functionality.
I posted a PR with a doc clarification. Also of note, .NET 8 added macOS CoW (clone) usage in File.Copy with https://github.com/dotnet/runtime/pull/79243
Also added the net8 info to the base library in https://github.com/microsoft/CopyOnWrite/pull/37
I use it in a 2-OS repo daily. On Linux and Mac the CoW base library returns
false
from the method that asks whether CoW works between paths or in a directory tree. Which means on Linux and Mac that regularFile.Copy
is used instead of a CoW link.
Ah, I read https://github.com/microsoft/CopyOnWrite/issues/10 and just naïvely assumed from the description that it would throw if used on Linux/macOS. That's great to hear.
I've not started any work to add in the Linux and Mac clone calls in the base library. If you're interested in contributing I'd welcome the added functionality.
Also of note, .NET 8 added macOS CoW (clone) usage in File.Copy with dotnet/runtime#79243
Linux too, as it turns out: https://github.com/dotnet/runtime/pull/64264
Not being super familiar with the CopyOnWrite library implementation, it makes me wonder what the right approach is here. Do you think it would make sense to try to port the Windows CoW code to the .NET BCL in a similar fashion? (Perhaps we should continue this discussion over on microsoft/CopyOnWrite?)
Thanks for finding the Linux PR, I had not seen that before. Pushed an iteration of the PR for this repo with this clarification that answers your Windows question:
On Linux and Mac the current behavior is to always fall back to regular file copies (File.Copy
), however File.Copy
automatically uses CoW for Linux (starting in .NET 7) and Mac (.NET 8). A similar PR for Windows did not make it into .NET, however there is work underway to integrate CoW into the Windows API in a possible future release.
Added Linux info to CoW library in https://github.com/microsoft/CopyOnWrite/pull/38
Will go ahead and close this one then. Thanks for the clarifications!
I understand that Microsoft.CopyOnWrite does not currently work on non-Windows, and I would assume the same applies to Microsoft.Build.CopyOnWrite. So what is the recommended pattern for consuming this package in a repo that's expected to be built on both Windows and Unix platforms? (The idea would be to take advantage of CoW on Windows and gracefully fall back to normal copy on Unix.)