From 0cc14be09dbd388edb7816f70b1a9dbfea2277d1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 10 Dec 2010 23:51:20 +0100 Subject: [PATCH] sftp_seek: fix The new SFTP write code caused a regression as the seek function no longer worked as it didn't set the write position properly. It should be noted that seeking is STRONGLY PROHIBITED during upload, as the upload magic uses two different offset positions and the multiple outstanding packets etc make them sensitive to change in the midst of operations. This functionality was just verified with the new example code sftp_append. This bug was filed as bug #202: Bug: http://trac.libssh2.org/ticket/202 --- src/sftp.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sftp.c b/src/sftp.c index 483d208..f24df35 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -1719,15 +1719,6 @@ libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *hnd, return rc; } -/* libssh2_sftp_seek - * Set the read/write pointer to an arbitrary position within the file - */ -LIBSSH2_API void -libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE *handle, size_t offset) -{ - if(handle) - handle->u.file.offset = offset; -} /* libssh2_sftp_seek64 * Set the read/write pointer to an arbitrary position within the file @@ -1736,7 +1727,16 @@ LIBSSH2_API void libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset) { if(handle) - handle->u.file.offset = offset; + handle->u.file.offset = handle->u.file.offset_sent = offset; +} + +/* libssh2_sftp_seek + * Set the read/write pointer to an arbitrary position within the file + */ +LIBSSH2_API void +libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE *handle, size_t offset) +{ + libssh2_sftp_seek64(handle, (libssh2_uint64_t)offset); } /* libssh2_sftp_tell