kio_smb: Change incorrect use of QUrl::adjusted()
ClosedPublic

Authored by marten on Mar 1 2019, 10:14 AM.

Details

Summary

Compiling this module produces a number of warnings all referring to the same source:

kio-extras/smb/kio_smb_internal.h: In member function 'void SMBUrl::setFileName(const QString&)':
kio-extras/smb/kio_smb_internal.h:96: warning: ignoring return value of 'QUrl QUrl::adjusted(QUrl::FormattingOptions) const', declared with attribute nodiscard

The problem code is trying to make a URL for a partial file being uploaded/copied. However, because QUrl::adjusted() does not modify the URL in place, the copy operation works but does not use the intended partial file name. For example, if the destination file is "smb://server/dir/foobar.ext", the partial file name used will be "smb://server/dir/foobar.extfoobar.ext.part". The complete file will eventually be saved under the correct name, but the name will be wrong if the transfer is aborted and the user wants to find the partial file.

There is also the possibility of an error if the file name is long and the destination server has a length limit, because it effectively doubles in length.

The change fixes the problem and simplifies the code by simply appending ".part" to the supplied URL path directly. No other part of the ioslave uses SMBUrl::setFileName() or SMBUrl::partUrl(), so this does not raise any compatibility problems.

Test Plan

Built kio_smb with this change. Observed no compiler warning messages, correct copying to and from SMB, and use of the correct partial file name.

Diff Detail

Repository
R320 KIO Extras
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
marten created this revision.Mar 1 2019, 10:14 AM
Restricted Application added projects: Dolphin, Frameworks. · View Herald TranscriptMar 1 2019, 10:14 AM
Restricted Application added subscribers: kfm-devel, kde-frameworks-devel. · View Herald Transcript
marten requested review of this revision.Mar 1 2019, 10:14 AM

Ping - anyone able to review please?

dfaure accepted this revision.Mar 27 2019, 8:26 AM
This revision is now accepted and ready to land.Mar 27 2019, 8:26 AM
sitter accepted this revision.Mar 27 2019, 9:55 AM

Ha, this is also much nicer looking. I love it! :)

This revision was automatically updated to reflect the committed changes.