Open itsWindows11 opened 3 months ago
It's worth first highlighting git and powershell, where renames are seen as move operations.
To bring this to our storage abstraction, renaming needs to be broken down into multiple primitive operations (enumerate, create, delete, read/write) that can safely be implemented with a "fallback" mechanism for filesystems that don't explicitly support renaming.
Here's what we have to work with:
IFolder
: Enumerate itemsIModifiableFolder
: Create item by name, Delete item, Enumerate itemsIFile
: Read/write stream resourceWhat we need to do renaming using these primitives:
IFile
: To rename a file, the inner content must be copied to a new resource with a new name, and the original resource deleted.IFolder
: To rename a folder, a new folder with the desired name must be created and all folder contents must be moved over, then the original content location is deleted. The reason we haven't tackled this yet is, again, all of the pitfalls you get with recursive operations. We can assume implementations with an extension interface to call would have no problem here since the functionality is explicitly "rename" and not the fallback definition of "create, copy, delete".
But the fallback implementation is a problem. We can't do recursive enumeration safely from within the abstraction. The safety checks must come from and be suited to the needs of the consumer, while the optimal type of enumeration is information held by the implementor (e.g. parallel for onedrive-style indexing, consecutive for system.io-style indexing).
Folder renaming is blocked for the same reason recursive move and recursive enumeration is blocked. I'm open to ideas.
There doesn't seem to be a method for renaming a file or folder. This is a necessary feature for a MVP (Minimum Viable Product) file manager where on modifiable folders you can rename a file or folder.
We can decide if we want it on the storable itself, i.e.
storable.RenameAsync("new name", ...)
or something likemodifiableFolder.RenameAsync(IStorableChild, "new name", ...)
. This area will conflict with issue #61.