diff --git a/sftp/kio_sftp.cpp b/sftp/kio_sftp.cpp --- a/sftp/kio_sftp.cpp +++ b/sftp/kio_sftp.cpp @@ -1418,7 +1418,6 @@ totalSize(fileSize); position(0); opened(); - finished(); } void sftpProtocol::read(KIO::filesize_t bytes) { @@ -1440,7 +1439,6 @@ const QByteArray fileData = QByteArray::fromRawData(buffer.data(), bytesRead); data(fileData); - finished(); } void sftpProtocol::write(const QByteArray &data) { @@ -1457,7 +1455,6 @@ } written(bytesWritten); - finished(); } void sftpProtocol::seek(KIO::filesize_t offset) { @@ -1472,7 +1469,6 @@ } position(sftp_tell64(mOpenFile)); - finished(); } void sftpProtocol::close() { diff --git a/smb/kio_smb.h b/smb/kio_smb.h --- a/smb/kio_smb.h +++ b/smb/kio_smb.h @@ -292,6 +292,8 @@ SMBUrl m_openUrl; const bool m_enableEEXISTWorkaround; /* Enables a workaround for some broken libsmbclient versions */ + // Close without calling finish(). Use this to close after error. + void closeWithoutFinish(); }; //========================================================================== diff --git a/smb/kio_smb_file.cpp b/smb/kio_smb_file.cpp --- a/smb/kio_smb_file.cpp +++ b/smb/kio_smb_file.cpp @@ -220,7 +220,7 @@ if(bytesRead < 0) { error( KIO::ERR_COULD_NOT_READ, m_openUrl.toDisplayString()); - close(); + closeWithoutFinish(); return; } else @@ -233,7 +233,7 @@ off_t res = smbc_lseek(m_openFd, 0, SEEK_SET); if (res == (off_t)-1) { error(KIO::ERR_COULD_NOT_SEEK, m_openUrl.path()); - close(); + closeWithoutFinish(); return; } } @@ -258,7 +258,7 @@ { qCDebug(KIO_SMB) << "Could not read " << m_openUrl; error( KIO::ERR_COULD_NOT_READ, m_openUrl.toDisplayString()); - close(); + closeWithoutFinish(); return; } @@ -278,7 +278,7 @@ { qCDebug(KIO_SMB) << "Could not write to " << m_openUrl; error( KIO::ERR_COULD_NOT_WRITE, m_openUrl.toDisplayString()); - close(); + closeWithoutFinish(); return; } @@ -290,16 +290,21 @@ off_t res = smbc_lseek(m_openFd, static_cast(offset), SEEK_SET); if (res == (off_t)-1) { error(KIO::ERR_COULD_NOT_SEEK, m_openUrl.path()); - close(); + closeWithoutFinish(); } else { qCDebug( KIO_SMB ) << "res" << res; position( res ); } } -void SMBSlave::close() +void SMBSlave::closeWithoutFinish() { smbc_close(m_openFd); +} + +void SMBSlave::close() +{ + closeWithoutFinish(); finished(); }