Commit effb511c authored by Harald Sitter's avatar Harald Sitter 🎶

sftp: successfully write files to proftpd servers

proftpd doesn't like zero size writes and returns with an error leading us
to assume that the write failed, when in fact it was fine eitherway because
we didn't write anything one way or the other.
so, instead just break out of the loop early. there's nothing lost by
us not doing that final EOF write since we don't need it from a protocol
POV.
the break occurs just before writing because preceding it is "spin-up" tech
opening the file and so forth. we need to have that run even when putting
a 0b file.

this successfully writes 0B, 1B, and 128M files both with partial markers
enabled and disabled to proftpd 1.3.6c

BUG: 419999
FIXED-IN: 20.04.1
parent 457ee4d5
......@@ -1794,6 +1794,17 @@ Result SFTPInternal::sftpPut(const QUrl &url, int permissions, JobFlags flags, i
} // file
} // dest.isEmpty
if (result == 0) {
// proftpd stumbles over zero size writes.
// https://bugs.kde.org/show_bug.cgi?id=419999
// http://bugs.proftpd.org/show_bug.cgi?id=4398
// At this point we'll have opened the file and thus created it.
// It's safe to break here as even in the ideal scenario that the server
// doesn't fall over, the write code is pointless because zero size writes
// do absolutely nothing.
break;
}
ssize_t bytesWritten = sftp_write(file, buffer.data(), buffer.size());
if (bytesWritten < 0) {
qCDebug(KIO_SFTP_LOG) << "Failed to sftp_write" << buffer.size() << "bytes."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment