D22528: KIO FTP: Fix file copy hanging when copying to existing file

Harald Sitter noreply at phabricator.kde.org
Fri Jul 19 13:50:06 BST 2019


sitter added a comment.


  Hm. I've had a quick look and I think the intent was that only the slavebase overridden functions call error or finished. So technically all internal functions that can have an error need to set an iError or return one so that the "public" function can then issue error() as needed. This seems to not very well enforced and probably never was, in fact there's a comment in the .h about this very fact
  
    // ------------------------------------------------------------------------
    // All the methods named ftpXyz are lowlevel methods that are not exported.
    // The implement functionality used by the public high-level methods. Some
    // low-level methods still use error() to emit errors. This behaviour is not
    // recommended - please return a boolean status or an error code instead!
    // ------------------------------------------------------------------------
  
  What I think may be best to resolve this is to split the class in two.
  
  The "public" class only has overrides of SlaveBase. It's functions are the only ones that may issue `error()` or `finished()`.
  The "private" class has all the supporting functions and has no access to SlaveBase so it cannot issue error or finished.
  This should be a very durable solution as even in the future no one will accidentally add another call to error or finished in one of the internal functions since they are in a different object and all error handling must be done via iError or some other system.
  
  In fact, I am thinking this is a case where one could just use exceptions. The private class could throw a simple exception on errors and in the public class we'd need nothing more than a try{}catch in all the public functions.

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D22528

To: ZaWertun, sitter, dfaure, cfeck
Cc: kde-frameworks-devel, LeGast00n, sbergeron, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190719/92fc7286/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list