ramondeklein/nwebdav

MoveHandler MoveAsync for collections copies children individually (potentially very slow for some backing stores)

CaptainPants opened this issue · 4 comments

MoveHandler move function for collections has no option to take advantage of moving a whole container, but instead creates a new container, moves contents one at a time, and then deletes the original.

I am working on a personal project that has an option for a GoogleDrive backing store. I would prefer to simply change the parent of the folder, retaining the ID of the folder itself.

https://github.com/ramondeklein/nwebdav/blob/master/NWebDav.Server/Handlers/MoveHandler.cs

This function:
private async Task MoveAsync(IStoreCollection sourceCollection, string sourceName, IStoreCollection destinationCollection, string destinationName, bool overwrite, IHttpContext httpContext, Uri baseUri, UriResultCollection errors)

I am happy to make the change in a branch and add a pull request, but would ideally like to coordinate on design.

My thinking is to add a function to IStoreCollection to check if a 'fast move' of a child collection is supported, and if so just tell it to use MoveItemAsync on the parent collection to do the move (the same as if it was a file). E.g. Task SupportsMovingCollections().

If I am just missing something and there is already an easier way, please let me know.

PS. Great library

You can use custom RequestHandlerFactory and MoveHandler (take a look at MoveHandler.MoveAsync)

I think this is a good idea and make moving collections much faster on stores that support it. The reason why it hasn't been implemented is to avoid issues with locking. I would have to look into this issue, because WebDAV locking is quite difficult to get right.

Thanks @ramondeklein, looks great.