Index: sources/storage/FileHandler.h =================================================================== diff -u -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 -r52310e33f540f84741a0eb2e2e91cbab1bc93d45 --- sources/storage/FileHandler.h (.../FileHandler.h) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) +++ sources/storage/FileHandler.h (.../FileHandler.h) (revision 52310e33f540f84741a0eb2e2e91cbab1bc93d45) @@ -85,11 +85,20 @@ /*! * \brief FileHandler::copyFile * \details Copies a file chunk by chunk + * \param vSource - the source path without filename + * \param vDestination - The destination path witout filename + * \param vFileName - The name of the file copying + * \param notifer - The function to call for announcing updates + * \param vIndex - The index to identify the file in the lsit + * \param vIsCancelled - A passed by reference param which allows cancelling mid copy by setting to true. + * This will delete the partially copied file at the destination * \return */ template - static int copyFile(const QString &vSource, const QString &vDestination, const QString &vFileName, const NotifierFunction *notifier = nullptr, quint32 vIndex = 0, bool *vIsCancelled = nullptr) + static int copyFile(const QString &vSource, const QString &vDestination, const QString &vFileName, const NotifierFunction *notifier = nullptr, quint32 vIndex = 0, bool &vIsCancelled = false) { + //DEBUG: qDebug()<< "Entering function : vIsCancelled " << vIsCancelled; + FileCopyError_Enums err = eOK; QDir srcDir = QFileInfo (vSource ).absoluteDir(); QDir dstDir = QFileInfo (vDestination ).absoluteDir(); @@ -124,7 +133,11 @@ qDebug() << "Dst: " << vDestination; while ( copySize ) { - if(vIsCancelled && *vIsCancelled) break; + if(vIsCancelled) + { + //DEBUG: qDebug()<< "vIsCancelled changed : " << vIsCancelled; + break; + } char chunkData[chunkSize] = {}; const qint64 readSize = srcFile.read (chunkData, chunkSize); if ( readSize < 0 ) { err = eSrcOpenError ; goto lErr; } @@ -157,7 +170,7 @@ if ( ! dstFile.flush() ) { err = eDstFlushError ; goto lErr; } dstFile.close(); - if ( vIsCancelled && *vIsCancelled ) + if ( vIsCancelled ) { // remove the log partially copied when cancel happened if ( !dstFile.remove() ) { err = eDstRemoveError ; goto lErr; } Index: sources/storage/Logger.cpp =================================================================== diff -u -r33f524bef52d793ead294ed8d7254d4385fb3459 -r52310e33f540f84741a0eb2e2e91cbab1bc93d45 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 33f524bef52d793ead294ed8d7254d4385fb3459) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 52310e33f540f84741a0eb2e2e91cbab1bc93d45) @@ -704,7 +704,7 @@ // qDebug() << it.key() << it.value() << mSource << mDestination; auto index = it.key (); auto filename = it.value(); - result = FileHandler::copyFile(mSource, mDestination + _logBasePathNames[vLogType], filename, ¬ifier, index, &_cancelExport); + result = FileHandler::copyFile(mSource, mDestination + _logBasePathNames[vLogType], filename, ¬ifier, index, _cancelExport); if (_cancelExport) { result = FileHandler::eOK;