Index: sources/device/DeviceController.cpp =================================================================== diff -u -rafc3ee7fbbb3ed76165002e1d486dc732ad374a6 -r93315aa549a91c6c0d6973248e9b903df9cc40a2 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision afc3ee7fbbb3ed76165002e1d486dc732ad374a6) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 93315aa549a91c6c0d6973248e9b903df9cc40a2) @@ -975,25 +975,28 @@ bool DeviceController::logBackup(const QString &vFileName) { - if ( ! gLongLogName ) return false; + if ( ! gLogUpload ) return false; // no log backup bool ok = true; + QString fileSrc = vFileName; QFileInfo fileInfo(vFileName); QString filePath(fileInfo.absolutePath()); QString fileBase(fileInfo.baseName()); QString fileSufx(fileInfo.completeSuffix().prepend(_Logger.logFileNamePendingSubExt())); QString fileDest(QString("%1/%2.%3").arg(filePath, fileBase, fileSufx)); - // DEBUG - // qDebug() << ""; - // qDebug() << vFileName; - // qDebug() << fileDest; - ok = QFile::rename(vFileName, fileDest); + // DEBUG qDebug() << __FUNCTION__ << "\n" << vFileName << "\n" << fileDest; + if ( gLogCompress ) { + fileSrc += _Logger.logFileNameCompressExt(); + fileDest += _Logger.logFileNameCompressExt(); + ok = FileHandler::backupFile(vFileName); + } + ok = QFile::rename(fileSrc, fileDest); return ok; } void DeviceController::onLogBackup(const QString &vFileName) { - if ( ! gLongLogName ) return; + if ( ! gLogUpload ) return; // no log backup ( slot ) bool ok = true; ok = logBackup( vFileName); @@ -1002,7 +1005,7 @@ bool DeviceController::logUpload(const QString &vFileName) { - if ( ! gLongLogName ) return false; + if ( ! gLogUpload ) return false; // no log Uploaded rename bool ok = true; QFileInfo fileInfo(vFileName); @@ -1015,10 +1018,7 @@ Logger::LogType logType = _Logger.logFileLogType(vFileName, filePath); ok = logType != Logger::eLogNone; if ( ! ok ) { LOG_APPED_UI(QString("CS Incorrect log upload type [%1]").arg(fileSufx)); goto lOut; } - // DEBUG - // qDebug() << ""; - // qDebug() << vFileName; - // qDebug() << fileDest; + // DEBUG qDebug() << __FUNCTION__ << "\n" << vFileName << "\n" << fileDest; ok = QFile::rename(filePath + vFileName, filePath + fileDest); lOut: @@ -1027,7 +1027,7 @@ void DeviceController::onLogUpload(const QString &vFileName) { - if ( ! gLongLogName ) return; + if ( ! gLogUpload ) return; // no log uploaded rename ( slot ) bool ok = true; ok = logUpload( vFileName); @@ -1076,7 +1076,7 @@ */ void DeviceController::findPendingLogs() { - if ( ! gLongLogName ) return; + if ( ! gLogUpload ) return; // no log upload pending detection static QString pendingLog = ""; if( _pendingCounter ) { @@ -1096,13 +1096,20 @@ // if there are pending files, // send a request only for the top on the list /// Note I thought it makes sense to send the oldest on the application and service logs - /// but there some conversation about the situation if something happens on the device, + /// but there are some conversation about the situation if something happens on the device, /// and it would be a critical situation to get the recent/top log and won't wait for the old ones to upload. // * When gets uploaded, moves from pending then next one comes to top // the process repeats until there is no file in pending + + bool uploadOldestFirst = true; //TODO: make if configurable(cfg, or cli) + if ( pendingFiles.count() ) { - // the most recent/first Tx file, to first ask for the current treatment which has just saved as pending on screen - _pendingLog = pendingFiles.first().absoluteFilePath(); + // the most recent/first log file, to first ask for the current log which has just been saved as pending + if ( uploadOldestFirst ) { + _pendingLog = pendingFiles.first().absoluteFilePath(); + } else { + _pendingLog = pendingFiles.last().absoluteFilePath(); + } QString message = pendingLog; LOG_DEBUG(message); emit didPendingLog( _pendingLog, FileHandler::sha256sum( _pendingLog ) );