Fixing bug where MTP slave does not return error in stat()/mimetype()

Authored by feverfew on Aug 26 2019, 9:17 AM.

Description

Fixing bug where MTP slave does not return error in stat()/mimetype()

Summary:
This patch fixes two cases where invalid KTMPFile objects would be treated as
valid. In particular, this would manifest in KIO::stat() and KIO::mimetype()
returning without error when they, in fact, should do. One would note that in
the rest of the code, KMTPFile objects that are received via
KMTPStorageInterface::getFileMetaData() always have a isValid() check applied
before use. The two previously mentioned functions, incorrectly, do not have
this check applied. This patch simply adds these necessary checks.

Test Plan:
KIOFuse uses KIO::stat() to complete a lookup. Before this patch lookup would
always succeed and this was determined to be because stat would always succeed.
This bug could be easily found as tab completion would never work correctly.
Trying to tab complete would seem to add what was already typed in to the
directory. With this patch applied, lookup no longer always succeeds and tab
completion now works.

Reviewers: chinmoyr, akrutzler, elvisangelaccio, dfaure

Reviewed By: dfaure

Subscribers: kde-frameworks-devel, kfm-devel, fvogt

Tags: Dolphin, Frameworks

Differential Revision: https://phabricator.kde.org/D23454

Details