Index: sources/storage/Logger.cpp =================================================================== diff -u -r25a12a9599c802d96ff5446a5ad80ddc30987ff9 -r5bb4a64727ce89d613ab0b79813b1a3f768291ff --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 25a12a9599c802d96ff5446a5ad80ddc30987ff9) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 5bb4a64727ce89d613ab0b79813b1a3f768291ff) @@ -497,7 +497,7 @@ // has been tested manually LOG_DEBUG(tr("Initializing log clean up")); int removeCount = 0; - auto logFiles = { eLogAppED , eLogDebug , eLogCloud }; + auto logFiles = { eLogAppED , eLogDebug , eLogCloud }; // TODO: UI (Linux denali user has no access to the CloudSync log folders to delete) auto logFile = { vLogType }; // Is mostly used for the txr files which are in separate partition. for ( const auto &iType : ( vLogType == eLogFiles ? logFiles : logFile ) ) { @@ -510,31 +510,30 @@ _logTypeMaxUsageLimit[iType]); // how many/much removeCount = fileInfoList.count(); // qDebug() << "@" << removeCount << fileInfoList; - if (removeCount) { - LOG_DEBUG(QString("Removing %1 logs of type (%2) more than %3% limit from folder %4") - .arg(removeCount) - .arg(mCExtension) - .arg(_logTypeMaxUsageLimit[iType]) - .arg(mCSource)); - for (const auto &info: fileInfoList) { - if (info.lastModified().date() == QDate().currentDate()) { - LOG_DEBUG(QString("Current day log %1 cannot be deleted").arg(info.fileName())); - } - else { - QString mFileName = mCSource + info.fileName(); - // DEBUG: qDebug() << "#" << mFileName; - bool ok = QFile::remove(mFileName); - if (ok) { - LOG_DEBUG(QString("Removing %1 succeeded").arg(mFileName)); - } else { - LOG_DEBUG(QString("Removing %1 failed" ).arg(mFileName)); - } - } + if ( ! removeCount ) { LOG_DEBUG(QString("No log file to delete for type(%1) more than %2% limit from folder %3") + .arg(mCExtension) + .arg(_logTypeMaxUsageLimit[iType]) + .arg(mCSource)); continue; } + LOG_DEBUG(QString("Removing %1 logs of type (%2) more than %3% limit from folder %4") + .arg(removeCount) + .arg(mCExtension) + .arg(_logTypeMaxUsageLimit[iType]) + .arg(mCSource)); + for (const auto &info: fileInfoList) { + bool isWritable = info.isWritable(); + bool isOldLog = info.lastModified().date() != QDate().currentDate(); + if ( ! isWritable ) { LOG_DEBUG(QString("Log %1 cannot be deleted" ).arg(info.fileName())); continue; } + if ( ! isOldLog ) { LOG_DEBUG(QString("Current day log %1 cannot be deleted" ).arg(info.fileName())); continue; } + + QString mFileName = mCSource + info.fileName(); + // DEBUG: qDebug() << "#" << mFileName; + bool ok = QFile::remove(mFileName); + if (ok) { + LOG_DEBUG(QString("Removing %1 succeeded").arg(mFileName)); + } else { + LOG_DEBUG(QString("Removing %1 failed" ).arg(mFileName)); } } - else { - LOG_DEBUG("No log file is deleted for " + mCExtension); - } } return removeCount; }