Index: sources/device/DeviceController.cpp =================================================================== diff -u -ra7c8f14c6d5420ea15cdbd8fc6e3c46bae1052cb -r8566686e033eaa3025180a735ce6f485e4fcaad4 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision a7c8f14c6d5420ea15cdbd8fc6e3c46bae1052cb) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 8566686e033eaa3025180a735ce6f485e4fcaad4) @@ -970,44 +970,67 @@ emit didPOSTCloudSyncData (vNetAddress); } -void DeviceController::onLogBackup(const QString &vFileName) +bool DeviceController::logBackup(const QString &vFileName) { + if ( ! gLongLogName ) return false; + + bool ok = true; QFileInfo fileInfo(vFileName); QString filePath(fileInfo.absolutePath()); QString fileBase(fileInfo.baseName()); - // ------------------------------------------------------------------------ TODO: Improve : get pending type extention - QString fileSufx(fileInfo.completeSuffix().prepend("u.")); + QString fileSufx(fileInfo.completeSuffix().prepend(_Logger.logFileNamePendingSubExt())); QString fileDest(QString("%1/%2.%3").arg(filePath, fileBase, fileSufx)); // DEBUG // qDebug() << ""; // qDebug() << vFileName; // qDebug() << fileDest; - QFile::rename(vFileName, fileDest); + ok = QFile::rename(vFileName, fileDest); + return ok; } -void DeviceController::onLogUpload(const QString &vFileName) +void DeviceController::onLogBackup(const QString &vFileName) { + if ( ! gLongLogName ) return; + + bool ok = true; + ok = logBackup( vFileName); + emit didLogBackup(ok, vFileName); +} + +bool DeviceController::logUpload(const QString &vFileName) +{ + if ( ! gLongLogName ) return false; + + bool ok = true; QFileInfo fileInfo(vFileName); - QString filePath(Storage::Log_Folder_Base); + QString filePath; QString fileBase(fileInfo.baseName()); - // ------------------------------------------------------------------------ TODO: Improve : get pending type extention - QString fileSufx(fileInfo.completeSuffix().remove("u.")); - // ------------------------------------------------------------------------ TODO: Improve : get type - if( fileSufx == "log" ) { - filePath += Storage::Log_Folder_Application; - } - // ------------------------------------------------------------------------ TODO: Improve : get type - if( fileSufx == "err" ) { - filePath += Storage::Log_Folder_Service; - } - QString fileDest(QString("%1.%2").arg(fileBase, fileSufx)); + QString ext = _Logger.logFileNamePendingSubExt(); + QString fileSufx(fileInfo.completeSuffix().remove(ext)); + QString fileDest = QString("%1.%2").arg(fileBase, fileSufx); + + 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; - QFile::rename(filePath + vFileName, filePath + fileDest); + + ok = QFile::rename(filePath + vFileName, filePath + fileDest); +lOut: + return ok; } +void DeviceController::onLogUpload(const QString &vFileName) +{ + if ( ! gLongLogName ) return; + + bool ok = true; + ok = logUpload( vFileName); + emit didLogUpload(ok, vFileName); +} + /*! * \brief DeviceController::checkConfugurationMountReady * \details Cheks if the system is ready to mount the encrypted partition. @@ -1050,6 +1073,8 @@ */ void DeviceController::findPendingLogs() { + if ( ! gLongLogName ) return; + static QString pendingLog = ""; if( _pendingCounter ) { _pendingCounter -- ; @@ -1061,9 +1086,7 @@ QFileInfoList pendingFiles; QString logLoc = Log_Folder_Base; - // ------------------------------------------------------------------------ TODO: Improve : get pending type extention - QString logExt = "*.u.*"; - + QString logExt = QString("*.%1*").arg(_Logger.logFileNamePendingSubExt()); // "*.u.*"; for( auto logFolder : { Log_Folder_Application, Log_Folder_Service/*, Log_Folder_CloudSync*/ } ) { pendingFiles = Storage::FileHandler::find( logLoc + logFolder, { logExt } ); // look into the list.