Fix sftp error 31 (proto 4 and 2)

See https://midnight-commander.org/ticket/3406#comment:13
and https://midnight-commander.org/ticket/3406#comment:16.

Both _lstat and _stat need to handle NO_SUCH_FILE while
copying to a remote sftp.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
xenogenesi 2017-01-10 16:48:44 +01:00 committed by Andrew Borodin
parent 1866f9169f
commit a241f472bf
1 changed files with 30 additions and 0 deletions

View File

@ -189,6 +189,12 @@ sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror)
libssh2_sftp_last_error (super_data->sftp_session) == LIBSSH2_FX_PERMISSION_DENIED)
return -EACCES;
/* perhaps the copy function tries to stat destination file
to make sure it's not overwriting anything */
if (res == LIBSSH2_ERROR_SFTP_PROTOCOL
&& libssh2_sftp_last_error (super_data->sftp_session) == LIBSSH2_FX_NO_SUCH_FILE)
return -ENOENT;
if (res != LIBSSH2_ERROR_EAGAIN)
{
sftpfs_ssherror_to_gliberror (super_data, res, mcerror);
@ -278,6 +284,12 @@ sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror)
libssh2_sftp_last_error (super_data->sftp_session) == LIBSSH2_FX_PERMISSION_DENIED)
return -EACCES;
/* perhaps the copy function tries to stat destination file
to make sure it's not overwriting anything */
if (res == LIBSSH2_ERROR_SFTP_PROTOCOL
&& libssh2_sftp_last_error (super_data->sftp_session) == LIBSSH2_FX_NO_SUCH_FILE)
return -ENOENT;
if (res != LIBSSH2_ERROR_EAGAIN)
{
sftpfs_ssherror_to_gliberror (super_data, res, mcerror);
@ -501,6 +513,13 @@ sftpfs_chmod (const vfs_path_t * vpath, mode_t mode, GError ** mcerror)
libssh2_sftp_last_error (super_data->sftp_session) == LIBSSH2_FX_PERMISSION_DENIED)
return -EACCES;
if (res == LIBSSH2_ERROR_SFTP_PROTOCOL
&& libssh2_sftp_last_error (super_data->sftp_session) == LIBSSH2_FX_FAILURE)
{
res = 0; /* need something like ftpfs_ignore_chattr_errors */
break;
}
if (res != LIBSSH2_ERROR_EAGAIN)
{
sftpfs_ssherror_to_gliberror (super_data, res, mcerror);
@ -527,6 +546,17 @@ sftpfs_chmod (const vfs_path_t * vpath, mode_t mode, GError ** mcerror)
if (res >= 0)
break;
if (res == LIBSSH2_ERROR_SFTP_PROTOCOL
&& libssh2_sftp_last_error (super_data->sftp_session) == LIBSSH2_FX_NO_SUCH_FILE)
return -ENOENT;
if (res == LIBSSH2_ERROR_SFTP_PROTOCOL
&& libssh2_sftp_last_error (super_data->sftp_session) == LIBSSH2_FX_FAILURE)
{
res = 0; /* need something like ftpfs_ignore_chattr_errors */
break;
}
if (res != LIBSSH2_ERROR_EAGAIN)
{
sftpfs_ssherror_to_gliberror (super_data, res, mcerror);