Index: sources/gui/GuiView.cpp =================================================================== diff -u -r86e9dfbff50cb7e16fd94c16c1c818cef3b47eac -r3a528c6f3fce8132de2791b55d3227e715d68898 --- sources/gui/GuiView.cpp (.../GuiView.cpp) (revision 86e9dfbff50cb7e16fd94c16c1c818cef3b47eac) +++ sources/gui/GuiView.cpp (.../GuiView.cpp) (revision 3a528c6f3fce8132de2791b55d3227e715d68898) @@ -242,10 +242,10 @@ // has been tested manually /// DEBUG: qDebug() << vReady << vTotal << vAvailable << vPercent << Storage::Available_Space_Percent; Q_UNUSED(vReady) - sdTotal ( vTotal ); - sdAvail ( vAvailable ); - sdPercent ( vPercent ); - sdIsLow ( vPercent <= Storage::Available_Space_Percent ); + sdTotal ( vTotal ); + sdAvail ( vAvailable ); + sdPercent ( vPercent ); + sdIsLow ( Storage::Log_Min_Available_Total_Space_IsLow(vPercent) ); } // disabled coco end Index: sources/storage/Logger.cpp =================================================================== diff -u -r86e9dfbff50cb7e16fd94c16c1c818cef3b47eac -r3a528c6f3fce8132de2791b55d3227e715d68898 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 86e9dfbff50cb7e16fd94c16c1c818cef3b47eac) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 3a528c6f3fce8132de2791b55d3227e715d68898) @@ -401,9 +401,14 @@ mOSource = mCSource; mOExtension = mCExtension; // Remove Logs + // TODO: It appeared to me that the filter on extension may not be necessary, since the folder of each type is different. + // NOTE: The filter on the extension comes from the idea that in the same folder(log) we may want to separate the event(log) from datum(dat) with different usage percentage. +#ifdef MIXED_EVENT_DATUM + mLogFileFilter = QString("*%1").arg(".*"); +#else mLogFileFilter = QString("*%1").arg(mCExtension); - // DEBUG: since it has been manually tested this will help next time for test. - // qDebug() << "@" << mCSource << mLogFileFilter << mCExtension << iType << _logTypeMaxUsageLimit[iType]; +#endif + // DEBUG: qDebug() << "@" << mCSource << mLogFileFilter << mCExtension << iType << _logTypeMaxUsageLimit[iType]; QFileInfoList fileInfoList = FileHandler::find(mCSource, {mLogFileFilter}, _logTypeMaxUsageLimit[iType]); removeCount = fileInfoList.count(); // qDebug() << "@" << removeCount << fileInfoList; @@ -419,8 +424,7 @@ } else { QString mFileName = mCSource + info.fileName(); - // DEBUG: since it has been manually tested this will help next time for test. - // qDebug() << "#" << mFileName; + // DEBUG: qDebug() << "#" << mFileName; bool ok = QFile::remove(mFileName); if (ok) { LOG_DEBUG(QString("Removing %1 succeeded").arg(mFileName)); @@ -489,8 +493,8 @@ Q_UNUSED(vTotal ) Q_UNUSED(vAvailable ) if ( ! vReady ) return; - /// DEBUG: qDebug() << vPercent << Storage::Available_Space_Percent; - if ( vPercent < Storage::Available_Space_Percent ) { + // DEBUG: qDebug() << vPercent << Storage::Available_Space_Percent; + if ( Storage::Log_Min_Available_Total_Space_IsLow(vPercent) ) { concurrentRemoveLogs(); } } Index: sources/storage/Logger.h =================================================================== diff -u -r86e9dfbff50cb7e16fd94c16c1c818cef3b47eac -r3a528c6f3fce8132de2791b55d3227e715d68898 --- sources/storage/Logger.h (.../Logger.h) (revision 86e9dfbff50cb7e16fd94c16c1c818cef3b47eac) +++ sources/storage/Logger.h (.../Logger.h) (revision 3a528c6f3fce8132de2791b55d3227e715d68898) @@ -122,24 +122,20 @@ { LogType::eLogTrtmt, ".log" }, }; - // be careful when defining these percentages - // 1 - Since now both the Log and Datum are in the same place and file they have same percentage. - // if separated then the percentage has to be separated - // 2 - the total in _logTypeExpiryDay is not 100 and it has to be summed up with Storage::Available_Space_Percent. - // so it is 50% for Event/Datum + 15% Service + 35% free = 100% total - // If the available SD-Card size is < Storage::Available_Space_Percent( 15 ) the remove logger will remove any of log types to retain percentage for each (50 for log, 15 for servc) - // The deletion will continue to get 35% free space, as has been calculated above. + // !!!!!!!!!! IMPORTANT !!!!!!!!!! + // be careful with these percentages + // please refer to the Storage namespace. const QHash _logTypeMaxUsageLimit { #ifdef MIXED_EVENT_DATUM - { LogType::eLogEvent, 50 }, // in percent - { LogType::eLogDatum, 50 }, // in percent + { LogType::eLogEvent, Storage::Log_Max_Allowable_AppED_Space_Percent }, + { LogType::eLogDatum, Storage::Log_Max_Allowable_AppED_Space_Percent }, #else - { LogType::eLogEvent, 25 }, // in percent - { LogType::eLogDatum, 25 }, // in percent + { LogType::eLogEvent, Storage::Log_Max_Allowable_Event_Space_Percent }, + { LogType::eLogDatum, Storage::Log_Max_Allowable_Datum_Space_Percent }, #endif - { LogType::eLogDebug, 15 }, // in percent + { LogType::eLogDebug, Storage::Log_Max_Allowable_Debug_Space_Percent }, // Not Sure yet so commented out in the remove. - { LogType::eLogTrtmt, 100}, // in percent // No Remove for now + { LogType::eLogTrtmt, Storage::Log_Max_Allowable_Trtmt_Space_Percent }, }; const char *_dateFormat = "yyyy_MM_dd" ; // date used in the file name Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -rec7f919fdb70ff29a8de627937e4ad7008e59c1c -r3a528c6f3fce8132de2791b55d3227e715d68898 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision ec7f919fdb70ff29a8de627937e4ad7008e59c1c) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 3a528c6f3fce8132de2791b55d3227e715d68898) @@ -40,7 +40,18 @@ const char *USB_File_System = "vfat"; // SD-CARD - const short Available_Space_Percent = 15; + 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 Used : 85 = 100 - 15 + // // Min Buffer : 10 = 85 - 75 + // IMPORTANT: we have to keep 10% buffer otherwise competition between filling and deleting logs will cause application to crash eventually. + short Log_Min_Available_Total_Space_IsLow(short vPercent) { return vPercent < Log_Min_Available_Total_Space_Percent; } + #ifdef BUILD_FOR_TARGET const char *SDCard_Base_Path_Name = "/media/sd-card/"; #else Index: sources/storage/StorageGlobals.h =================================================================== diff -u -rec7f919fdb70ff29a8de627937e4ad7008e59c1c -r3a528c6f3fce8132de2791b55d3227e715d68898 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision ec7f919fdb70ff29a8de627937e4ad7008e59c1c) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 3a528c6f3fce8132de2791b55d3227e715d68898) @@ -30,7 +30,14 @@ extern const char *USB_File_System; // SD-CARD - extern const short Available_Space_Percent; + 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 short Log_Min_Available_Total_Space_IsLow ( short vPercent ); + extern const char *SDCard_Base_Path_Name; // Screenshot store folder