After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 572786 - [PATCH] Add support for the native webdav MOVE operation
[PATCH] Add support for the native webdav MOVE operation
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: webdav backend
1.0.x
Other All
: Normal enhancement
: ---
Assigned To: gvfs-maint
gvfs-maint
: 727096 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-02-22 22:28 UTC by Mads Chr. Olesen
Modified: 2014-04-13 21:00 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Implement native webdav move operation (2.44 KB, patch)
2009-02-22 22:28 UTC, Mads Chr. Olesen
needs-work Details | Review
Implement native webdav move (update patch to apply to HEAD) (2.53 KB, patch)
2010-07-25 18:33 UTC, Mads Chr. Olesen
needs-work Details | Review
dav: Use the native MOVE operation for moving (6.08 KB, patch)
2014-03-26 23:08 UTC, Ross Lagerwall
committed Details | Review

Description Mads Chr. Olesen 2009-02-22 22:28:07 UTC
The attached patch adds support for moving of files, so not to have to resort to the copy+delete fallback.
Comment 1 Mads Chr. Olesen 2009-02-22 22:28:57 UTC
Created attachment 129286 [details] [review]
Implement native webdav move operation
Comment 2 Alexander Larsson 2009-03-02 12:22:12 UTC
Hmm, I don't know the dav backend very well, but I don't think this handles overwrite errors correctly. See the API docs for g_file_move, wrt to overwrites for the details of what errors should be reported.
Comment 3 Mads Chr. Olesen 2009-03-02 13:15:57 UTC
Yes, you're right :-/

Doing simple nautilus tests, it seems that overwriting a file over a directory, or dir over file fails.

Everything else seems to be fine: Dir over dir asks for merging, file over file asks for overwriting.

I'll work on a revised patch...
Comment 4 Cosimo Cecchi 2009-04-28 12:08:20 UTC
Setting patch status as for comment #2 and comment #3.
Comment 5 Mads Chr. Olesen 2009-06-15 18:21:14 UTC
I have done some more investigation into this, and would like some more advice, if someone can give any.

The server I have available (some version of Apache) does not like if you try to overwrite a file with a directory or vice versa.

Overwriting file with directory returns "400 Bad Request"
Overwriting directory with file returns "301 Moved Permanently" (possibly because it requires a trailing slash, but in any case the redirect can not be followed as no Location header is supplied...)

If someone can observe better/different behaviour, I would very much like to know.

In any case, I would recommend (since the added functionality is very useful, e.g. when moving large folders) applying the patch in its current state, with an additional comment like
/* FIXME: Does not handle overwriting file with directory or vice versa */
Comment 6 Mads Chr. Olesen 2009-07-27 17:54:45 UTC
Any comments on this?
The patch makes it many times more pleasant to move files on WebDav shares - actually makes it usable in my case. I do not see anyone wanting to download 100Mb just to upload them again, when it should be an operation done on the server.

A further comment is that the implementation is heavily borrowed from the ftp backend - which also seems to fail to handle overwrite errors.

May I suggest that the patch be applied, and new bugs filed against the ftp and dav backend re. handling overwrites?
Comment 7 Mads Chr. Olesen 2009-07-27 17:56:43 UTC
Comment on attachment 129286 [details] [review]
Implement native webdav move operation

Unsetting needs-work flag. Please re-set if my suggested plan is not acceptable.
Comment 8 Mads Chr. Olesen 2010-07-25 18:33:50 UTC
Created attachment 166533 [details] [review]
Implement native webdav move (update patch to apply to HEAD)
Comment 9 Petr Tomasek 2010-09-27 07:50:28 UTC
Please, this patch is badly needed!
Comment 10 Tomas Bzatek 2010-10-14 12:35:31 UTC
Review of attachment 166533 [details] [review]:

I made few more tests and found out that overwriting directory with a file results in the old directory being removed with all subfolders and files. Certainly G_IO_ERROR_IS_DIRECTORY should be returned. Same situation with overwriting a file with a directory. Also, directory vs. directory overwrite removes the old one, we should return G_IO_ERROR_WOULD_MERGE here.

I know this is more a server behaviour (or perhaps libsoup) and according to your other concerns I suggest to stat destination before doing an operation.

Note that all my tests were performed on apache2 via gnome-user-share. The behaviour may be different elsewhere but we should avoid any data loss in any case.

::: daemon/gvfsbackenddav.c
@@ +2255,3 @@
+  guint        status;
+
+  /* FIXME: what about G_FILE_COPY_NOFOLLOW_SYMLINKS and G_FILE_COPY_ALL_METADATA? */

My understanding of G_FILE_COPY_ALL_METADATA is that it does matter for copying, not for moving already existing files (which have their attributes).

For symlinks, I guess this is handled by the webserver itself (via some directives) - at least I can't see any symlinks using gnome-user-share. Neither cadaver or gvfsd-dav is showing any of them, they're just ignored.
Comment 11 Ross Lagerwall 2014-03-26 15:45:25 UTC
*** Bug 727096 has been marked as a duplicate of this bug. ***
Comment 12 matt.ward 2014-03-26 15:52:35 UTC
No previous comments on this issue since 2010 and it results in dataloss (e.g. version history) as per Bug 727096. Is there any likelyhood this will receive any attention?
Comment 13 Ross Lagerwall 2014-03-26 18:01:26 UTC
I can try take a look at this in the next few days.
Comment 14 Ross Lagerwall 2014-03-26 23:08:23 UTC
Created attachment 273033 [details] [review]
dav: Use the native MOVE operation for moving

This saves unnecessary round trips when moving files and directories.
Based on a patch by Mads Chr. Olesen and the GLocalFile implementation.

Backups are not yet implemented.  It tries to cover the various cases of
overwriting files with directories and vice versa by doing what
GLocalFile does.
Comment 15 Ondrej Holy 2014-04-02 14:45:55 UTC
Review of attachment 273033 [details] [review]:

It looks good, just few notes:

::: daemon/gvfsbackenddav.c
@@ +2740,3 @@
+                                G_IO_ERROR,
+                                G_IO_ERROR_CANT_CREATE_BACKUP,
+                                _("backups not supported yet"));

Would be better to use "Backup file creation failed" to be consistent at least in backend.

@@ +2778,3 @@
+                }
+              else if (source_ft == G_FILE_TYPE_DIRECTORY)
+                {

Is the following code needed? Overwrite header should be enough, shouldn't be?
Comment 16 Ross Lagerwall 2014-04-02 16:00:47 UTC
(In reply to comment #15)
> Review of attachment 273033 [details] [review]:
> 
> It looks good, just few notes:
> 
> ::: daemon/gvfsbackenddav.c
> @@ +2740,3 @@
> +                                G_IO_ERROR,
> +                                G_IO_ERROR_CANT_CREATE_BACKUP,
> +                                _("backups not supported yet"));
> 
> Would be better to use "Backup file creation failed" to be consistent at least
> in backend.
> 
> @@ +2778,3 @@
> +                }
> +              else if (source_ft == G_FILE_TYPE_DIRECTORY)
> +                {
> 
> Is the following code needed? Overwrite header should be enough, shouldn't be?

Yes it is needed. Apache at least chokes if you try and overwrite a file with a dir:

> MOVE /dav/test/ HTTP/1.1
> Soup-Debug-Timestamp: 1396454334
> Soup-Debug: SoupSessionSync 1 (0x11e3100), SoupMessage 6 (0x7f8a500063a0), SoupSocket 3 (0x7f8a5000aa30), restarted
> Host: localhost
> Overwrite: T
> Accept-Encoding: gzip, deflate
> Accept-Language: en-us, en;q=0.9
> Connection: Keep-Alive
> Destination: http://localhost/dav/file/
> User-Agent: gvfs/1.20.1
  
< HTTP/1.1 400 Bad Request
< Soup-Debug-Timestamp: 1396454334
< Soup-Debug: SoupMessage 6 (0x7f8a500063a0)
< Date: Wed, 02 Apr 2014 15:58:54 GMT
< Server: Apache/2.4.9 (Fedora)
< Content-Length: 226
< Connection: close
< Content-Type: text/html; charset=iso-8859-1
< 
< <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
< <html><head>
< <title>400 Bad Request</title>
< </head><body>
< <h1>Bad Request</h1>
< <p>Your browser sent a request that this server could not understand.<br />
< </p>
< </body></html>
Comment 17 Ross Lagerwall 2014-04-02 17:11:39 UTC
(In reply to comment #15)
> Review of attachment 273033 [details] [review]:
> 
> It looks good, just few notes:
> 
> ::: daemon/gvfsbackenddav.c
> @@ +2740,3 @@
> +                                G_IO_ERROR,
> +                                G_IO_ERROR_CANT_CREATE_BACKUP,
> +                                _("backups not supported yet"));
> 
> Would be better to use "Backup file creation failed" to be consistent at least
> in backend.
> 

OK, I will change that.  I was being consistent with the ftp and sftp backends :-)
Comment 18 Ondrej Holy 2014-04-03 10:46:34 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > Is the following code needed? Overwrite header should be enough, shouldn't be?
> 
> Yes it is needed. Apache at least chokes if you try and overwrite a file with a

Ok then. I tried it on free public webdav provided by http://www.ajaxfilebrowser.com/ and looked like working...

(In reply to comment #17)
> (In reply to comment #15)
> > Would be better to use "Backup file creation failed" to be consistent at least
> > in backend.
> > 
> 
> OK, I will change that.  I was being consistent with the ftp and sftp backends
> :-)

Unfortunately it is quite inconsistent between backends... :-/
Comment 19 Ross Lagerwall 2014-04-13 21:00:17 UTC
Pushed to master as b4387906ba3d5e73025e19245b5058e0db17c84f.  Thanks!