cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re-using SFTP connection and CURLOPT_FTP_CREATE_MISSING_DIRS issue

From: Brian Ulm <ulmbj1_at_gmail.com>
Date: Wed, 12 Mar 2008 08:57:00 -0400

I have found what I believe to be an issue when reusing an SFTP connection
and the CURLOPT_FTP_CREATE_MISSING_DIRS option.

Say I have two files I would like to upload:

File 1: sftp://myserver.com/home/user/TestDir1/file.bmp";
and
File 2: "sftp://myserver.com/home/user/TestDir2/file.bmp";

The folders TestDir1 and TestDir2 are not created on the server - only
/home/user/ is already there.

The command sequence is:
1.) Initialize CURL handle.
2.) Setup CURL options (including CURLOPT_FTP_CREATE_MISSING_DIRS)
3.) Upload File #1
4.) Call curl_easy_reset();
5.) Setup the same CURL options (including CURLOPT_FTP_CREATE_MISSING_DIRS)
6.) Upload File #2

During Step #3, the directory TestDir1 will be created on the server since
it does not exist and the file will upload successfully.

However, when reaching Step #6, TestDir2 will not be created and CURL
returns error 78.

Here is the output log:

File 1 = sftp://myserver.com/home/user/TestDir1/file.bmp
File 2 = sftp://myserver.com/home/user/TestDir2/file.bmp

Uploading File 1:
* About to connect() to myserver.com port 22 (#0)
* Trying xx.xx.xx.xx... * connected
* Connected to myserver.com (xx.xx.xx.xx) port 22 (#0)
* SSH authentication methods available: publickey,password
* Using ssh public key file id_dsa.pub
* Using ssh private key file id_dsa
* SSH public key authentication failed: Unable to open public key file
* Initialized password authentication
* Authentication complete
* Upload failed: No such file or directory
* Creating directory '/home'
* Creating directory '/home/user'
* Creating directory '/home/user/TestDir1'
* Connection #0 to host myserver.com left intact
curlRes = 0

Uploading File 2:
* Re-using existing connection! (#0) with host myserver.com
* Connected to myserver.com (xx.xx.xx.xx) port 22 (#0)
* Upload failed: No such file or directory
* Connection #0 to host myserver.com left intact
* Remote file not found
curlRes = 78

If I change the curl_easy_reset() to curl_easy_cleanup() and do not reuse
the connection, everything works as expected and both files are uploaded.
Received on 2008-03-12