ngraham added a comment.

  We don't actually need to create a messagebox because it's up to the caller 
to display the error in an appropriate manner. For example, Dolphin shows 
errors inline rather than with dialog boxes. So we shouldn't create a 
messagebox at all.
  
  Let's see if we can figure out what to do:
  
  Elsewhere in `src/core/copyjob.cpp`, in `CopyJobPrivate::copyNextFile()`, we 
already check for the size of each individual file:
  
    if (m_freeSpace < (*it).size) {
        q->setError(ERR_DISK_FULL);
        q->emitResult();
        return;
    }
  
  This works, but results in a half-finished copy, as it dies once it 
encounters the first file that doesn't fit. In 
`CopyJobPrivate::statCurrentSrc()`, the comment `//TODO warn user beforehand if 
space is not enough` gives us a clue for what to do: just add the same logic 
there, but check the total size of all copied files rather than the size of 
each individual file. So you would add the following:
  
    if (m_totalSize > m_freeSpace) {
        q->setError(ERR_DISK_FULL);
        q->emitResult();
        return;
    }
  
  For bonus points, set the error text to something appropriate for each error. 
For example, something like this would work for the "whole transfer is too big" 
case:
  
    q->setErrorText(
            xi18n("There will not be enough free space available at 
<filename>%1</filename> to hold the file (%2 are required but only %3 are 
available",
                m_globalDest.toLocalFile(),
                KIO::convertSize(m_totalSize),
                KIO::convertSize(m_freeSpace) ) );

INLINE COMMENTS

> copyjob.cpp:887
>          qCDebug(KIO_COPYJOB_DEBUG)<<"Stating finished. To 
> copy:"<<m_totalSize<<", available:"<<m_freeSpace;
>          //TODO warn user beforehand if space is not enough
> +        if (m_totalSize > m_freeSpace) {

You can remove this comment now. :)

REPOSITORY
  R241 KIO

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

To: shubham, pino, dfaure, broulik
Cc: ngraham, dfaure, pino, kde-frameworks-devel, michaelh, bruns

Reply via email to