curl-library
SFTP "File already completely downloaded" but the file is empty
Date: Mon, 26 Mar 2012 12:15:46 +0200
Hello,
With libcurl 7.23.1 and libssh2 1.3.0
I'm trying to download files from a particular server. As we can see in the log below, the files are not empty :
[sftp_list] -rw-r----- 1 0 0 1109 Feb 01 01:32 %13348364340002%O093108548006900%SFTP%POLLABLE%39fea1006kshqnn300012npg [12:49:10]
[sftp_list] -rw-r----- 1 0 0 1109 Feb 01 01:31 %13348364340002%O093108548006900%SFTP%POLLABLE%39fedh006kshqmfg003708h1 [12:49:10]
[sftp_list] -rw-r----- 1 0 0 1114 Feb 01 01:31 %13348364340002%O093108548006900%SFTP%POLLABLE%39fea1006kshqkup00012nm1 [12:49:10]
What is surprising :
[sftp_fget] get file sftp://sftp.tradinggrid.gxs.com/AMR52527/././POLLABLE/%2513348364340002%25O093108548006900%25SFTP%25POLLABLE%2539fea1006kshqnn300012npg from directory [12:49:10]
* About to connect() to sftp.tradinggrid.gxs.com port 22 (#0)
* Trying 204.90.130.72... *** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:10]
* connected
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:10]
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:10]
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:11]
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:11]
* SSH authentication methods available: publickey,password
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:11]
* Initialized password authentication
* Authentication complete
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:11]
...
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:12]
* File already completely downloaded
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:12]
...
*** progress_callback: client 0.000000, total 0.000000, dlnow 0.000000 [12:49:13]
* Connection #0 to host sftp.tradinggrid.gxs.com left intact
[sftp_fget] get file sftp://sftp.tradinggrid.gxs.com/AMR52527/././POLLABLE/%2513348364340002%25O093108548006900%25SFTP%25POLLABLE%2539fea1006kshqnn300012npg OK. [12:49:13]
[sftp_fget] remote file size: 0 bytes, transfered 0 [12:49:13]
bfXFTP_getas(%13348364340002%O093108548006900%SFTP%POLLABLE%39fea1006kshqnn300012npg,/ usr/local/tx/users/editest/tmp/FTPFETCH54034/00000001) returns 1
We see that the file write callback is never called, which could explain why the files are empty.
Our explanation :
The log "* file already completely downloadedl" is displayed by libcurl when the function libssh2_sftp_stat_ex returns an attrs.filesize to 0 (zero).
It seems that the stat function is not supported by the GXS server.
After analyzing the complete log, it turns out that the progress callback does not return the file size.
Consequently, this means that this feature is not available on all servers and that we need to change the libcurl to implement a GetFileSize function.
IMPORTANT : this case has already been reported to you : http://curl.haxx.se/mail/archive-2009-01/0114.html <http://curl.haxx.se/mail/archive-2009-01/0114.html>
Are you agree with our possible explanation ?
Many thanks.
Salutations / Regards
______________________ Generix Group, Collaborative Business ________________________
Hafed NEDJARI * Support TradeXpress Pôle Industriel
Avant d'imprimer, pensons ŕ l'environnement / Think twice before printing
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html