Skip to content

Commit

Permalink
Merge #3271
Browse files Browse the repository at this point in the history
3271: [sftp] Remove sshfs append workaround r=townsend2010 a=sharder996

Fixes #3129 

Co-authored-by: sharder996 <[email protected]>
  • Loading branch information
bors[bot] and sharder996 authored Oct 31, 2023
2 parents 7e4dc40 + dfeb421 commit 642f5d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
20 changes: 14 additions & 6 deletions src/ssh/ssh_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,19 @@ std::string mp::SSHProcess::read_std_error()

std::string mp::SSHProcess::read_stream(StreamType type, int timeout)
{
mpl::log(mpl::Level::debug, category,
fmt::format("{}:{} {}(type = {}, timeout = {}): ", __FILE__, __LINE__, __FUNCTION__,
static_cast<int>(type), timeout));
mpl::log(mpl::Level::trace,
category,
fmt::format("{}:{} {}(type = {}, timeout = {}): ",
__FILE__,
__LINE__,
__FUNCTION__,
static_cast<int>(type),
timeout));
// If the channel is closed there's no output to read
if (ssh_channel_is_closed(channel.get()))
{
mpl::log(mpl::Level::debug, category,
mpl::log(mpl::Level::trace,
category,
fmt::format("{}:{} {}(): channel closed", __FILE__, __LINE__, __FUNCTION__));
return std::string();
}
Expand All @@ -132,14 +138,16 @@ std::string mp::SSHProcess::read_stream(StreamType type, int timeout)
do
{
num_bytes = ssh_channel_read_timeout(channel.get(), buffer.data(), buffer.size(), is_std_err, timeout);
mpl::log(mpl::Level::debug, category,
mpl::log(mpl::Level::trace,
category,
fmt::format("{}:{} {}(): num_bytes = {}", __FILE__, __LINE__, __FUNCTION__, num_bytes));
if (num_bytes < 0)
{
// Latest libssh now returns an error if the channel has been closed instead of returning 0 bytes
if (ssh_channel_is_closed(channel.get()))
{
mpl::log(mpl::Level::debug, category,
mpl::log(mpl::Level::trace,
category,
fmt::format("{}:{} {}(): channel closed", __FILE__, __LINE__, __FUNCTION__));
return output.str();
}
Expand Down
11 changes: 0 additions & 11 deletions src/sshfs_mount/sftp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,19 +581,8 @@ int mp::SftpServer::handle_open(sftp_client_message msg)
mode |= QIODevice::ReadOnly;

if (flags & SSH_FXF_WRITE)
{
mode |= QIODevice::WriteOnly;

// This is needed to workaround an issue where sshfs does not pass through
// O_APPEND. This is fixed in sshfs v. 3.2.
// Note: This goes against the default behavior of open().
if (flags == SSH_FXF_WRITE)
{
mode |= QIODevice::Append;
mpl::log(mpl::Level::info, category, "adding sshfs O_APPEND workaround");
}
}

if (flags & SSH_FXF_APPEND)
mode |= QIODevice::Append;

Expand Down

0 comments on commit 642f5d9

Please sign in to comment.