Index: en_US.udic =================================================================== diff -u -r70986eda0c1b55e62935f500014d0aa72f7262fe -r202d42b05e2c2924ea56e2063c5a9726d736bd9d --- en_US.udic (.../en_US.udic) (revision 70986eda0c1b55e62935f500014d0aa72f7262fe) +++ en_US.udic (.../en_US.udic) (revision 202d42b05e2c2924ea56e2063c5a9726d736bd9d) @@ -216,3 +216,4 @@ Gui param qry +decrypted Index: sources/storage/Logger.cpp =================================================================== diff -u -r75e10e5c2ada62906baded5ba8731977e51b1357 -r202d42b05e2c2924ea56e2063c5a9726d736bd9d --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 75e10e5c2ada62906baded5ba8731977e51b1357) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 202d42b05e2c2924ea56e2063c5a9726d736bd9d) @@ -260,8 +260,8 @@ /*! * \brief Logger::onCryptSetupMount - * \details the handlet for the _DeviceController::didCryptSetupMount - * to set the treatment fodler when the encrypted parttion is ready + * \details the handler for the _DeviceController::didCryptSetupMount + * to set the treatment folder when the encrypted partition is ready * and successfully decrypted and mounted. * It checks to make sure the folder exist and is able to be written and read. */ @@ -272,10 +272,10 @@ // use the Settings path first (/var/configurations (Encrypted Partition)) if ( ! QDir (basePath ).exists( )) { basePath = Storage::Standard_tmp; goto lOut; } - if ( ! FileHandler::makeFolder (basePath + Storage::Log_Folder_Treatment )) { basePath = Storage::Standard_tmp; goto lOut; } + if ( ! FileHandler::makeFolder (basePath + Storage::Txr_Folder_Treatment )) { basePath = Storage::Standard_tmp; goto lOut; } lOut: - _logPathNames[vLogType] = basePath + Storage::Log_Folder_Treatment; + _logPathNames[vLogType] = basePath + Storage::Txr_Folder_Treatment; emit didLogPathSet(vLogType, _logPathNames[vLogType]); FileHandler::errOut(tr("The '%1' folder selected for the treatment reports").arg(_logPathNames[vLogType])); @@ -491,13 +491,16 @@ * \details Remove old logs by iterating in the log/service folders and look for expired logs. * \return count file(s) have been removed. */ -int Logger::removeLogs() +int Logger::removeLogs(LogType vLogType) { // Storage::FileHandler::find("/media/denali/0CAA-40C1/log/", {"*.err"}, 15); return 0; // has been tested manually LOG_DEBUG(tr("Initializing log clean up")); int removeCount = 0; - for ( const auto &iType : { eLogAppED , eLogDebug , eLogTrtmt } ) { + auto logTypes = { eLogAppED , eLogDebug , eLogCloud , eLogTrtmt }; + auto logType = { vLogType }; + + for ( const auto &iType : ( vLogType == eLogAll ? logTypes : logType ) ) { QString mCSource = _logPathNames [iType]; QString mCExtension = _logFileNameExt[iType]; // DEBUG: qDebug() << "@" << mCSource << mLogFileFilter << mCExtension << iType << _logTypeMaxUsageLimit[iType]; @@ -539,13 +542,13 @@ * \return always returns true for now. * \note This method uses QtConcurrent run to execute the FileHandler copyFolder method. */ -bool Logger::concurrentRemoveLogs() +bool Logger::concurrentRemoveLogs(LogType vLogType) { // disabled coco begin validated: This needs user interaction to check the old files deleted // has been tested manually LOG_DEBUG("Remove Logs Starting"); emit didRemoveLogs(true); - QFuture mFuture = QtConcurrent::run(this, &Logger::removeLogs); + QFuture mFuture = QtConcurrent::run(this, &Logger::removeLogs, vLogType); _removeLogsWatcher.setFuture(mFuture); return true; } @@ -631,8 +634,8 @@ if ( ! vReady ) return; // DEBUG: qDebug() << vPercent << Storage::Available_Space_Percent; - if ( Storage::Log_Min_Available_Total_Space_IsLow(vPercent) ) { - concurrentRemoveLogs(); + if ( Storage::Txr_Min_Available_Total_Space_IsLow(vPercent) ) { + concurrentRemoveLogs(eLogTrtmt); } } // disabled coco end Index: sources/storage/Logger.h =================================================================== diff -u -rc97b99199d1be46f7cfa99908308ce98c8578285 -r202d42b05e2c2924ea56e2063c5a9726d736bd9d --- sources/storage/Logger.h (.../Logger.h) (revision c97b99199d1be46f7cfa99908308ce98c8578285) +++ sources/storage/Logger.h (.../Logger.h) (revision 202d42b05e2c2924ea56e2063c5a9726d736bd9d) @@ -86,9 +86,11 @@ eLogAppED, ///< Application Events and Data : Massages on the CANBus eLogDebug, ///< Application Error : Service logs - eLogTrtmt, ///< Treatment Log Files + eLogCloud, ///< CloudSync Log Files : CloudSync debug logs + eLogTrtmt, ///< Treatment Rep Files : Treatment Report files - eLogType_Count, + eLogType_Count , + eLogAll , }; Q_ENUM(LogType) @@ -104,19 +106,22 @@ const QHash _logBasePathNames { { LogType::eLogAppED, Storage::Log_Folder_Application}, { LogType::eLogDebug, Storage::Log_Folder_Service }, - { LogType::eLogTrtmt, Storage::Log_Folder_Treatment }, + { LogType::eLogCloud, Storage::Log_Folder_CloudSync }, + { LogType::eLogTrtmt, Storage::Txr_Folder_Treatment }, }; const QHash _logNames { // Will be used for the logging in the file { LogType::eLogAppED, "Log" }, { LogType::eLogDebug, "Service" }, + { LogType::eLogCloud, "Cloud" }, { LogType::eLogTrtmt, "Treatment" }, }; const QHash _logFileNameExt { { LogType::eLogAppED, ".log" }, // Application log { LogType::eLogDebug, ".err" }, // Application error - { LogType::eLogTrtmt, ".txr" }, // Treatment report + { LogType::eLogCloud, ".log" }, // CloudSync debug + { LogType::eLogTrtmt, ".txr" }, // Treatment report }; // !!!!!!!!!! IMPORTANT !!!!!!!!!! @@ -125,7 +130,8 @@ const QHash _logTypeMaxUsageLimit { { LogType::eLogAppED, Storage::Log_Max_Allowable_AppED_Space_Percent }, { LogType::eLogDebug, Storage::Log_Max_Allowable_Debug_Space_Percent }, - { LogType::eLogTrtmt, Storage::Log_Max_Allowable_Trtmt_Space_Percent }, + { LogType::eLogCloud, Storage::Log_Max_Allowable_Cloud_Space_Percent }, + { LogType::eLogTrtmt, Storage::Txr_Max_Allowable_Trtmt_Space_Percent }, }; const char *_dateFormat = "yyyy_MM_dd" ; // date used in the file name @@ -194,9 +200,9 @@ // ----- Remove Old Logs structure private: - int removeLogs(); + int removeLogs(LogType vLogType = eLogAll); private slots: // this slot is thread safe and can be called from outside but preferred not to. - bool concurrentRemoveLogs(); + bool concurrentRemoveLogs(LogType vLogType = eLogAll); void onRemoveLogs(); void onCryptSetupMount (bool vPass); Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -r0536992850014cee0a949958ce56c0008615da41 -r202d42b05e2c2924ea56e2063c5a9726d736bd9d --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 0536992850014cee0a949958ce56c0008615da41) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 202d42b05e2c2924ea56e2063c5a9726d736bd9d) @@ -54,18 +54,25 @@ const char *USB_File_System = "vfat"; // SD-CARD - const short Log_Min_Available_Total_Space_Percent = 15; // Min free : 15 // always has to be 15 percent free space available, less than this triggers the log cleanup. - const short Log_Max_Allowable_Event_Space_Percent = 25; - const short Log_Max_Allowable_Datum_Space_Percent = 25; - const short Log_Max_Allowable_AppED_Space_Percent = Log_Max_Allowable_Event_Space_Percent + Log_Max_Allowable_Datum_Space_Percent; // 50 - const short Log_Max_Allowable_Debug_Space_Percent = 15; - const short Log_Max_Allowable_Trtmt_Space_Percent = 10; - // // Max Usage : 75 = 25 + 25 + 15 + 10 + // // Max Usage : 80 = 25 + 25 + 15 + 15 // // Max Used : 85 = 100 - 15 - // // Min Buffer : 10 = 85 - 75 + // // Min Buffer : 5 = 85 - 80 // IMPORTANT: we have to keep 10% buffer otherwise competition between filling and deleting logs will cause application to crash eventually. + const short Log_Min_Available_Total_Space_Percent = 15; // Min free : 15 // always has to be 15 percent free space available, less than this triggers the log cleanup. + const short Log_Max_Allowable_AppED_Space_Percent = 50; + const short Log_Max_Allowable_Debug_Space_Percent = 15; + const short Log_Max_Allowable_Cloud_Space_Percent = 15; short Log_Min_Available_Total_Space_IsLow(short vPercent) { return vPercent < Log_Min_Available_Total_Space_Percent; } + // Settings/Encrypted + // the settings are roughly using the 5MB round it to 8MB to be 25% of 32MB of total encrypted partition. + // therefore the Txr shall not use more than 75% to leave the 25 for settings. + // when reaches that percent will be deleted to get total usage of 50% + // 50% percent of 32MB is 16MB which is enough to keep 10K (estimated each txr are 4K rounded to 5K and doubled.) of ~1600 files. + const short Txr_Min_Available_Total_Space_Percent = 25; // min space needed for settings by the current definitions. + const short Txr_Max_Allowable_Trtmt_Space_Percent = 50; // the treatment files are moved to the encrypted partition. + short Txr_Min_Available_Total_Space_IsLow(short vPercent) { return vPercent < Txr_Min_Available_Total_Space_Percent; } + #ifdef BUILD_FOR_TARGET const char *SDCard_Base_Path_Name = "/media/sd-card/"; #else @@ -132,13 +139,18 @@ #endif } - // Please notice that is the folder not the path + // and it needs to be concatenated after SDCard_Base_Path_Name for each build configuration const char *Log_Folder_Base = SDCard_Base_Path_Name; // Base Log Folder const char *Log_Folder_Application = "log/" ; // Event/Data Log const char *Log_Folder_Service = "service/" ; // Service Log - const char *Log_Folder_Treatment = "treatment/" ; // Treatment Log + const char *Log_Folder_CloudSync = "cloudsync/log/" ; // CloudSync Log + // Txr_Max_Allowable_Trtmt_Space_Percent notice that is the folder not the path + + const char *Txr_Folder_Base = Settings_Path_Name ; // Base Txr Folder + const char *Txr_Folder_Treatment = "treatment/" ; // Treatment Rep + // TODO : These need to be removed from here because they are only used in their specific classes. // Date and Time const char *Date_Time_Set_Sh = "date_time_set.sh"; Index: sources/storage/StorageGlobals.h =================================================================== diff -u -r0536992850014cee0a949958ce56c0008615da41 -r202d42b05e2c2924ea56e2063c5a9726d736bd9d --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 0536992850014cee0a949958ce56c0008615da41) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 202d42b05e2c2924ea56e2063c5a9726d736bd9d) @@ -39,13 +39,15 @@ // SD-CARD extern const short Log_Min_Available_Total_Space_Percent; - extern const short Log_Max_Allowable_Event_Space_Percent; - extern const short Log_Max_Allowable_Datum_Space_Percent; extern const short Log_Max_Allowable_AppED_Space_Percent; extern const short Log_Max_Allowable_Debug_Space_Percent; - extern const short Log_Max_Allowable_Trtmt_Space_Percent; + extern const short Log_Max_Allowable_Cloud_Space_Percent; extern short Log_Min_Available_Total_Space_IsLow ( short vPercent ); + extern const short Txr_Min_Available_Total_Space_Percent; + extern const short Txr_Max_Allowable_Trtmt_Space_Percent; + extern short Txr_Min_Available_Total_Space_IsLow ( short vPercent ); + extern const char *SDCard_Base_Path_Name; // Screenshot store folder @@ -83,8 +85,11 @@ extern const char *Log_Folder_Base; // Base Log Folder extern const char *Log_Folder_Application; // Event/Data Log extern const char *Log_Folder_Service; // Service Log - extern const char *Log_Folder_Treatment; // Treatment Log + extern const char *Log_Folder_CloudSync; // CloudSync Log + extern const char *Txr_Folder_Base; // Base Txr Folder + extern const char *Txr_Folder_Treatment; // Treatment Rep + // Date and Time extern const char *Date_Time_Set_Sh; Index: sources/storage/TreatmentLog.cpp =================================================================== diff -u -r0536992850014cee0a949958ce56c0008615da41 -r202d42b05e2c2924ea56e2063c5a9726d736bd9d --- sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 0536992850014cee0a949958ce56c0008615da41) +++ sources/storage/TreatmentLog.cpp (.../TreatmentLog.cpp) (revision 202d42b05e2c2924ea56e2063c5a9726d736bd9d) @@ -283,7 +283,7 @@ * \details sets the treatment log path if the given type is treatment log, with the path, vLogPath. * If the given vLogPath is empty, the defaults in Storage will be used. * \sa Storage::SDCard_Base_Path_Name - * \sa Storage::Log_Folder_Treatment + * \sa Storage::Txr_Folder_Treatment * \param vLogType - The Log type of type Logger::LogType * \param vLogPath - the path to be set and used. */ @@ -293,7 +293,7 @@ if ( vLogPath.trimmed().isEmpty() ) { _treatmentLogPath = QString("%1%2") .arg(Storage::Settings_Path()) - .arg(Storage::Log_Folder_Treatment ); + .arg(Storage::Txr_Folder_Treatment ); } else { _treatmentLogPath = vLogPath; @@ -491,7 +491,7 @@ bool ok = true; QString status = ""; QString dstPath = Storage::USB_Mount_Point ; - dstPath += Storage::Log_Folder_Treatment ; + dstPath += Storage::Txr_Folder_Treatment ; QString srcFile = _lastTxInfo.mFileName ; QString srcFileName = QFileInfo(srcFile).fileName() ; QString dstFile = dstPath + srcFileName;