diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2008-08-01 18:41:14 +0000 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2008-08-01 18:41:14 +0000 |
commit | 42cabc14d44b69af1df71f6f1e0ae8ccb66a8287 (patch) | |
tree | b22e3da7f99239407b3f125d2330a9b20dbeb223 /lib | |
parent | a948ca1669ffe302308616c59eb5733383295a17 (diff) |
Added support for --append on SFTP uploads. Unfortunately, OpenSSH doesn't
support this so it goes untested.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ssh.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1198,6 +1198,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) break; case SSH_SFTP_UPLOAD_INIT: + { + unsigned long flags; /* * NOTE!!! libssh2 requires that the destination path is a full path * that includes the destination file and name OR ends in a "/" @@ -1221,13 +1223,19 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) } } + if(data->set.ftp_append) + /* Try to open for append, but create if nonexisting */ + flags = LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_APPEND; + else if (data->state.resume_from > 0) + /* If we have restart position then open for append */ + flags = LIBSSH2_FXF_WRITE|LIBSSH2_FXF_APPEND; + else + /* Clear file before writing (normal behaviour) */ + flags = LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC; + sshc->sftp_handle = libssh2_sftp_open(sshc->sftp_session, sftp_scp->path, - /* If we have restart position then open for append */ - (data->state.resume_from > 0)? - LIBSSH2_FXF_WRITE|LIBSSH2_FXF_APPEND: - LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC, - data->set.new_file_perms); + flags, data->set.new_file_perms); if(!sshc->sftp_handle) { if(libssh2_session_last_errno(sshc->ssh_session) == @@ -1322,6 +1330,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn) state(conn, SSH_STOP); } break; + } case SSH_SFTP_CREATE_DIRS_INIT: if(strlen(sftp_scp->path) > 1) { |