sftp: seek: Don't flush buffers on same offset
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
This commit is contained in:
parent
fe347a702f
commit
486bb37621
27
src/sftp.c
27
src/sftp.c
@ -2132,21 +2132,24 @@ libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *hnd,
|
|||||||
LIBSSH2_API void
|
LIBSSH2_API void
|
||||||
libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset)
|
libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset)
|
||||||
{
|
{
|
||||||
if(handle) {
|
if(!handle)
|
||||||
handle->u.file.offset = handle->u.file.offset_sent = offset;
|
return;
|
||||||
/* discard all pending requests and currently read data */
|
if(handle->u.file.offset == offset && handle->u.file.offset_sent == offset)
|
||||||
sftp_packetlist_flush(handle);
|
return;
|
||||||
|
|
||||||
/* free the left received buffered data */
|
handle->u.file.offset = handle->u.file.offset_sent = offset;
|
||||||
if (handle->u.file.data_left) {
|
/* discard all pending requests and currently read data */
|
||||||
LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
|
sftp_packetlist_flush(handle);
|
||||||
handle->u.file.data_left = handle->u.file.data_len = 0;
|
|
||||||
handle->u.file.data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* reset EOF to False */
|
/* free the left received buffered data */
|
||||||
handle->u.file.eof = FALSE;
|
if (handle->u.file.data_left) {
|
||||||
|
LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
|
||||||
|
handle->u.file.data_left = handle->u.file.data_len = 0;
|
||||||
|
handle->u.file.data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* reset EOF to False */
|
||||||
|
handle->u.file.eof = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libssh2_sftp_seek
|
/* libssh2_sftp_seek
|
||||||
|
Loading…
x
Reference in New Issue
Block a user