Arlodotexe / OwlCore.Storage

The most flexible file system abstraction, ever. Built in partnership with the UWP Community.
16 stars 4 forks source link

Renaming storables #66

Open itsWindows11 opened 3 months ago

itsWindows11 commented 3 months ago

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 like modifiableFolder.RenameAsync(IStorableChild, "new name", ...). This area will conflict with issue #61.

Arlodotexe commented 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:

What we need to do renaming using these primitives:

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.