Index: sources/device/DeviceController.cpp =================================================================== diff -u -reb918e27185e683e1d6a2b3ef0c621d173d561a5 -r2afdc76a7d8f97a518da0158e9bd08217de41a97 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision eb918e27185e683e1d6a2b3ef0c621d173d561a5) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 2afdc76a7d8f97a518da0158e9bd08217de41a97) @@ -239,7 +239,7 @@ // The treatment logs are held in a separate partition from the unencrypted // logs and need a separate disk space usage check - encryptedPartitionSpaceCheck(); + settingsPartitionSpaceCheck(); #endif } @@ -367,31 +367,54 @@ } /*! - * \brief DeviceController::encryptedPartitionSpaceCheck + * \brief DeviceController::settingsPartitionSpaceCheck * \details Checks the disk space of the encrypted partition */ -void DeviceController::encryptedPartitionSpaceCheck() +void DeviceController::settingsPartitionSpaceCheck() { - bool mCIsReady = false; - bool mCIsReadOnly = false; - qint64 mCTotal = 0; - qint64 mCAvailable = 0; - quint8 mPercent = 0; + static bool mInitialized = false; + // Old Info ; // Current info + static bool mOIsReady = false; bool mCIsReady = false; + static bool mOIsReadOnly = false; bool mCIsReadOnly = false; + static qint64 mOAvailable = 0; qint64 mCAvailable = 0; + static quint8 mOPercent = 0; quint8 mCPercent = 0; - mCIsReady = driveSpaceCheck(Storage::Encrypted_Partition_Path, mCTotal, mCAvailable, &mCIsReadOnly); -#if BUILD_FOR_DESKTOP - mCIsReady = true; // it is set to always true since on desktop a local folder is used for the encrypted folder which doesn't need (un)mount. -#endif + qint64 mCTotal = 0; + mCIsReady = driveSpaceCheck(Storage::Settings_Path(), mCTotal, mCAvailable, &mCIsReadOnly); - if(!mCIsReady) qDebug()<<"NOT READY"; + //DEBUG: qDebug()<< "Checking space for path of : " << Storage::Settings_Path() << " mCTotal " << mCTotal << " available " << mCAvailable; - mPercent = mCTotal ? ((100 * mCAvailable) / mCTotal) : 0; - qDebug()<<"var percent "<< mPercent; - if (Log_Min_Available_Total_Space_IsLow(mPercent)) { - //DEBUG qDebug()<< (QString("Encrypted partition space lower than %1%").arg(Log_Min_Available_Total_Space_Percent)); - LOG_DEBUG(QString("Encrypted partition space lower than %1%").arg(Log_Min_Available_Total_Space_Percent)); - emit didEncryptedPartitionSpaceLow(); + if (mOIsReadOnly != mCIsReadOnly || mOIsReady != mCIsReady || ! mInitialized ) { + mOIsReadOnly = mCIsReadOnly; + mOIsReady = mCIsReady; + mInitialized = true; + //DEBUG:0: qDebug() << " ~~~~~~~~~~ " << __FUNCTION__ << mInitialized << mCIsReady << mOIsReady << mCIsReadOnly << mOIsReadOnly; + emit didSettingsPartitionStateChange(mCIsReady, mCIsReadOnly); } + //NOTE: this if block has to be independent of the mOIsReady != mCIsReady + // because current and old may be the same all the time and then this if block will not execute + // and reaches to the log and fills the log unnecessarily. + if (! mCIsReady ) { + mOPercent = 0; + mOAvailable = 0; + emit didSettingsPartitionSpaceChange(mCIsReady, mCTotal, mCAvailable, mCPercent); + return; + } + + mCPercent = mCTotal ? ((100 * mCAvailable) / mCTotal) : 0; + if (mCPercent < _minRequiredAvailableSpacePercent) { + LOG_DEBUG(QString("Settings partition space lower than %1%").arg(_minRequiredAvailableSpacePercent)); + emit didSettingsPartitionSpaceChange(mCIsReady, mCTotal, mCAvailable, mCPercent); + emit didSDCardSpaceTooLow(_minRequiredAvailableSpacePercent); + } + + /// DEBUG: qDebug() << Storage::SDCard_Base_Path_Name << mCIsReady << mOTotal << mCTotal << (mOTotal == mCTotal) << mOAvailable << mCAvailable << (mOAvailable == mCAvailable) << mPercent << mCIsReadOnly; + if (mOPercent != mCPercent && mOAvailable != mCAvailable ) { + mOPercent = mCPercent ; + mOAvailable = mCAvailable ; + emit didSettingsPartitionSpaceChange(mCIsReady, mCTotal, mCAvailable, mCPercent); + /// DEBUG: qDebug() << Storage::SDCard_Base_Path_Name << mCIsReady << mCTotal << mCAvailable << mPercent ; + } }