Offset problem in the ftp module


I have found a problem with the ftp-module when downloading multiple
files in one xfer. The problem is that the ftp-module doesn't reset the
offset variable after one file has finished downloading and before the
next one starts.

This results in that only parts of the second file are downloaded if it
is bigger than the first one or a 451 response from the server if the
second one is smaller (the offset is larger then the file size of the
second file).

The solution that I tried is to always reset the offset variable when a
226 response is received, which I think only happens after a whole file
has finished downloading. This also seemed to work in practice.

Here is a patch that adds such a check in the function

d.c gnome-vfs-2.6.1/modules/ftp-method.c
--- gnome-vfs-2.6.1-vanilla/modules/ftp-method.c        2004-03-19
11:54:47.000000000 +0100
+++ gnome-vfs-2.6.1/modules/ftp-method.c        2004-05-04
20:10:26.183077120 +0200
@@ -158,6 +158,9 @@
        gint response = conn->response_code;
        switch (response) {
+       case 226:
+         conn->offset = 0;
+         break;
        case 421:
        case 426:

The patch is made against version 2.6.1 of gnome-vfs and tested on
fedora core2 test3. 

I'm not sure if my patch solves the real problem or just deals with the
symptoms of something else. If it is a real solution I'm willing to
create a new patch that moves the detection of the 226 code and the
reset of the offset variable to a more suitable place then in the
ftp_response_to_vfs_result function. That will require a little more
work though due to the current handling of response codes in the


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]