Index: sources/storage/FileHandler.h =================================================================== diff -u -r1ed15b374613c81883e697cad25e55399e7abc17 -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/storage/FileHandler.h (.../FileHandler.h) (revision 1ed15b374613c81883e697cad25e55399e7abc17) +++ sources/storage/FileHandler.h (.../FileHandler.h) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -54,6 +54,7 @@ eSrcReadError , eDstWriteError , eDstFlushError , + eDstRemoveError , }; public: @@ -87,7 +88,7 @@ * \return */ template - static int copyFile(const QString &vSource, const QString &vDestination, const QString &vFileName, const NotifierFunction *notifier = nullptr, quint32 vIndex = 0) + static int copyFile(const QString &vSource, const QString &vDestination, const QString &vFileName, const NotifierFunction *notifier = nullptr, quint32 vIndex = 0, bool *vIsCancelled = nullptr) { FileCopyError_Enums err = eOK; QDir srcDir = QFileInfo (vSource ).absoluteDir(); @@ -123,6 +124,7 @@ qDebug() << "Dst: " << vDestination; while ( copySize ) { + if(vIsCancelled && *vIsCancelled) break; char chunkData[chunkSize] = {}; const qint64 readSize = srcFile.read (chunkData, chunkSize); if ( readSize < 0 ) { err = eSrcOpenError ; goto lErr; } @@ -155,6 +157,12 @@ if ( ! dstFile.flush() ) { err = eDstFlushError ; goto lErr; } dstFile.close(); + if ( vIsCancelled && *vIsCancelled ) + { + // remove the log partially copied when cancel happened + if ( !dstFile.remove() ) { err = eDstRemoveError ; goto lErr; } + } + qDebug() << "\nFinish"; return eOK;