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
This commit is contained in:
Daniel Stenberg 2010-12-10 23:51:20 +01:00
parent 499b989d46
commit 0cc14be09d

View File

@ -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