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 140583 - Multi-file transfer via FTP results in truncated files
Multi-file transfer via FTP results in truncated files
Status: RESOLVED FIXED
Product: gnome-vfs
Classification: Deprecated
Component: Module: ftp
2.5.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-vfs maintainers
gnome-vfs maintainers
Depends on:
Blocks:
 
 
Reported: 2004-04-20 11:05 UTC by Roderich Schupp
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.5/2.6



Description Roderich Schupp 2004-04-20 11:05:47 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);
Comment 1 Christophe Fergeau 2004-04-20 11:33:01 UTC
Shouldn't it be done in ftp_connection_acquire instead ?
Comment 2 Roderich Schupp 2004-04-20 13:19:30 UTC
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...
Comment 3 Christophe Fergeau 2004-04-20 13:33:53 UTC
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.
Comment 4 Christophe Fergeau 2004-05-17 18:00:16 UTC
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.