Return appropriate error code from browse_stat_path() instead of trying to deal with the error internally.
ClosedPublic

Authored by madcatx on Jul 10 2017, 9:50 PM.

Details

Summary

Current behavior of browse_stat_path() can result in both finished() and error() being signaled to KIO. This patch adjusts the logic to prevent this case.

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 10 2017, 9:50 PM

What if we make browse_stat_path() return the error code if there is an error or 0 otherwise? This way the caller can choose whether to call finished() or reportError() + error(). The ignore_errors argument would also become useless.

What if we make browse_stat_path() return the error code if there is an error or 0 otherwise? This way the caller can choose whether to call finished() or reportError() + error(). The ignore_errors argument would also become useless.

That would be a much less kludgy fix but I did not want to touch any of the control flow more than I had to at this point. I can take a closer look at the code and rearrange it to make it work in the way you suggested.

Don't worry about that. If the control flow is broken it should be changed.

Okay, I will try to rework this in a more sensible way.

madcatx updated this revision to Diff 16548.Jul 12 2017, 8:28 AM
madcatx retitled this revision from Do not call finished() after error() has been called to Return appropriate error code from browse_stat_path() instead of trying to deal with the error internally..
madcatx edited the summary of this revision. (Show Details)

Change the logic of browse_stat_path() instead of working around its current behavior.

elvisangelaccio accepted this revision.Jul 12 2017, 9:34 AM

Looks good to me now. Does this completely fix https://bugs.kde.org/show_bug.cgi?id=376344 now?

This revision is now accepted and ready to land.Jul 12 2017, 9:34 AM

As far as I can tell I have no issues with unwritable directories anymore. Note that this patch introduces a small behavior change, when browse_stat_path() encounters ENOENT or ENOTDIR, there is a warning displayed if browse_stat_path() is called from stat(). If it gets called from the listDir() loop, the error is ignored silently. Previous behavior displayed the warning in both cases. I suppose that treating ENOENT and ENOTDIR as an error from stat() and displaying a warning from listDir() would make more sense. I'd prefer to submit this as a separate patch if possible.

This revision was automatically updated to reflect the committed changes.