[PATCH 2/4] Add reportWarning() method
ClosedPublic

Authored by madcatx on Jul 12 2017, 10:46 PM.

Details

Summary

Restore the warning dialog when a non-existent file is encountered in the listDir loop.

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.
madcatx created this revision.Jul 12 2017, 10:46 PM
smb/kio_smb_browse.cpp
316

The return value of the lambda is never used, can't we just use a void function?

smb/kio_smb_browse.cpp
316

Ah forget it, you use it in D6663.

smb/kio_smb_browse.cpp
308

listDir() is already big enough, I think we should probably make this lambda a proper private method.
And a method named browse_stat_path_warning doesn't tell me much about what it does. How about a simpler reportWarning() method (similar to reportError()) instead?

madcatx updated this revision to Diff 16762.Jul 16 2017, 1:00 AM
madcatx retitled this revision from [PATCH 2/4] Warn if a nonexistent entry is encountered in listDir loop to [PATCH 2/4] Warn if an error is returned from browse_stat_path().

Instead of hardwiring ENOENT and ENOTDIR errnos provide a more generic function that will generate a warning if any from a list of errors occurs.

elvisangelaccio requested changes to this revision.Jul 16 2017, 9:20 AM
elvisangelaccio added inline comments.
smb/kio_smb_browse.cpp
108

There is one argument missing (the error). But I think this method should just be reportWarning(int error) with a switch (like in reportError()) that converts ENOENT and friends to user-friendly sentences.

384–388

Actually what I meant was something like:

if (int err = browse_stat_path(m_current_url, udsentry) {
    reportWarning(err);
}

It is slightly more verbose than your approach, but imho the code becomes easier to understand.

This revision now requires changes to proceed.Jul 16 2017, 9:20 AM
smb/kio_smb_browse.cpp
384–388

Sorry, this should actually be:

const int err = browse_stat_path(m_current_url, udsentry);
if (err == ENOENT || err == ENOTDIR) {
    reportWarning(err);
}
madcatx updated this revision to Diff 16769.Jul 16 2017, 12:14 PM
madcatx edited edge metadata.
madcatx retitled this revision from [PATCH 2/4] Warn if an error is returned from browse_stat_path() to [PATCH 2/4] Add reportWarning() method.

Check for the error code explicitly and report an error from reportWarning() method

elvisangelaccio accepted this revision.Jul 16 2017, 12:38 PM

Thanks, looks good to me now.

This revision is now accepted and ready to land.Jul 16 2017, 12:38 PM
This revision was automatically updated to reflect the committed changes.