GNOME Bugzilla – Bug 140583
Multi-file transfer via FTP results in truncated files
Last modified: 2004-12-22 21:47:04 UTC
Try copying from an ftp URL to a local URL, the copy must involve several files (so that the FTP connection gets re-used), e.g. use gnomevfs-copy from an ftp directoyry URL to a local directory. Most files transferred (except the file transferred first) will have length zero or will have been truncated on the beginning of the file. Reason is that the field "offset" in the FtpConnection struct is not reset on file open. This causes the "broken transfer detected, let's issue a FTP REST command" logic to fire for everything but the first file transferred. Suggested patch: --- gnome-vfs2-2.6.0-ORIG/modules/ftp-method.c 2004-03-19 10:42:33.000000000 +0100 +++ gnome-vfs2-2.6.0/modules/ftp-method.c 2004-04-16 17:25:21.000000000 +0200 @@ -823,6 +823,7 @@ if (result != GNOME_VFS_OK) return result; + conn->offset = 0; if (mode & GNOME_VFS_OPEN_READ) { conn->operation = FTP_READ; result = do_path_transfer_command (conn, "RETR", uri, context);
Shouldn't it be done in ftp_connection_acquire instead ?
IMHO ftp_connection_acquire is just a caching form of ftp_connection_create. The conceptual problem is that the "offset" field doesn't really belong to the FtpConnection struct, because it pertains to an open "VFS file", as its usage in do_transfer_command, do_tell and do_seek shows. OTOH, the net result of doing it in ftp_connection_acquire is the same as doing it in do_open...
Putting it in ftp_connection_acquire or in do_open is a bit different. If we put it in do_open, this means the offset should only be reset when a ftp uri is opened, while if it's put in ftp_connection_acquire, that means the offset should always be reset when a connection is reused. Since ftp_connection_acquire is called by several other functions, that makes a difference. I haven't looked enough at the issue to know which behaviour is the appropriate one, but my first reaction is that the offset must be reset every time a connection is reused.
Ok, I committed Index: modules/ftp-method.c =================================================================== RCS file: /cvs/gnome/gnome-vfs/modules/ftp-method.c,v retrieving revision 1.99 diff -u -r1.99 ftp-method.c --- modules/ftp-method.c 1 Apr 2004 15:10:51 -0000 1.99 +++ modules/ftp-method.c 16 May 2004 10:50:46 -0000 @@ -757,6 +757,10 @@ conn); g_hash_table_insert (spare_connections, uri, possible_connections); + + /* Reset offset */ + conn->offset = 0; + /* make sure connection hasn't timed out */ result = do_basic_command(conn, "PWD", cancellation); if (result != GNOME_VFS_OK) { to CVS HEAD and the gnome-2-6 branch.