Commit 9ca35979 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

smb: always close in ::get

previously the error scenario didn't return early because of the close, so
instead put the close in a scopeguard and return immediately after error.
otherwise we'd emit both error and finished resulting in a state violation.
parent 2b5d8bb3
Pipeline #168251 passed with stage
in 5 minutes and 5 seconds
......@@ -10,7 +10,9 @@
#include <QMimeDatabase>
#include <QMimeType>
#include <QScopeGuard>
#include <QVarLengthArray>
#include <KLocalizedString>
#include <future>
......@@ -59,6 +61,9 @@ void SMBSlave::get(const QUrl &kurl)
error(KIO::ERR_CANNOT_OPEN_FOR_READING, url.toDisplayString());
return;
}
auto filefdClose = qScopeGuard([filefd] {
smbc_close(filefd);
});
KIO::filesize_t totalbytesread = 0;
QByteArray filedata;
......@@ -106,9 +111,9 @@ void SMBSlave::get(const QUrl &kurl)
}
if (future.get() != KJob::NoError) { // check if read had an error
error(future.get(), url.toDisplayString());
return;
}
smbc_close(filefd);
data(QByteArray());
if (totalbytesread != static_cast<KIO::filesize_t>(st.st_size)) {
qCWarning(KIO_SMB_LOG) << "Got" << totalbytesread << "bytes but expected" << st.st_size;
......
Supports Markdown
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