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.
Details
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.
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.
Change the logic of browse_stat_path() instead of working around its current behavior.
Looks good to me now. Does this completely fix https://bugs.kde.org/show_bug.cgi?id=376344 now?
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.