From be8f5254617e67f5d681af4565e3ca9aeff06284 Mon Sep 17 00:00:00 2001 From: hama Date: Sun, 14 Feb 2016 12:21:22 +0100 Subject: [PATCH] rebackgui: fix of statistics --- appl/rebackgui/BackupEngine.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/appl/rebackgui/BackupEngine.cpp b/appl/rebackgui/BackupEngine.cpp index 1f71848..254f3ed 100644 --- a/appl/rebackgui/BackupEngine.cpp +++ b/appl/rebackgui/BackupEngine.cpp @@ -160,8 +160,10 @@ void BackupTask::copyFile(int index, const QString& relPath, QFileInfo info(source); if (m_verboseLevel >= VerboseStandard) m_mainWindow->addToFileList(source + " " + ReQStringUtils::readableSize(info.size())); + m_mutex.lock(); m_processedFiles++; m_processedBytes += info.size(); + m_mutex.unlock(); QString errorMsg = ReFileUtils::copy(source, target, &info, m_buffer); if (! errorMsg.isEmpty()){ @@ -401,7 +403,7 @@ void ChecksumOfTargetTask::run() qint64 processedBytes, hotBytes; int hotFiles, processedFiles; m_mutex.lock(); - hotFiles = m_hotFiles * 2; + hotFiles = m_hotFiles; hotBytes = m_hotBytes * 2; processedBytes = m_processedBytes; processedFiles = m_processedFiles; @@ -453,6 +455,7 @@ void CleanTask::run() QString relPath, node; QString info; QDateTime start = QDateTime::currentDateTime(); + int processedFiles, hotFiles; while (! m_shouldStop){ m_mutex.lock(); if (m_files.size() == 0) @@ -461,7 +464,9 @@ void CleanTask::run() info = m_files.first(); m_files.removeFirst(); } - m_processedFiles++; + hotFiles = m_hotFiles; + if (! info.isEmpty()) + processedFiles = ++m_processedFiles; m_mutex.unlock(); if (info.isEmpty()){ if (m_searchReady) @@ -491,9 +496,10 @@ void CleanTask::run() case CmdRemoveDir: if (_rmdir(I18N::s2b(relPath)) != 0){ int errNo = errno; - if (stat(I18N::s2b(relPath), &info2) == 0) + if (stat(I18N::s2b(relPath), &info2) == 0){ error(QObject::tr("cannot remove directory (%1): %2").arg(errNo) .arg(relPath)); + } } else if (m_verboseLevel >= VerboseStandard) m_mainWindow->addToFileList("/ " + relPath); break; @@ -526,16 +532,13 @@ void CleanTask::run() break; } if (m_verboseLevel > VerboseQuiet){ - double factor = double(m_processedFiles) / max(1, m_hotFiles); + double factor = double(processedFiles) / max(1, hotFiles); qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL, - tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6") - .arg(m_processedFiles) - .arg(m_hotFiles) - .arg(ReQStringUtils::readableSize(m_processedBytes)) - .arg(ReQStringUtils::readableSize(m_hotBytes)) - .arg(m_processedBytes / 1024.0 / 1024 * 1000 - / max(1.0, (double) duration), 0, 'f', 3) + tr("%1 of %2 files %3 files/sec runtime: %6") + .arg(processedFiles) + .arg(hotFiles) + .arg(processedFiles * 1000.0 / max(1.0, (double) duration), 0, 'f', 3) .arg(ReQStringUtils::runtimeEstimation(start, factor))); } } @@ -767,6 +770,7 @@ bool SearchTargetTask::removeOlder(const QString& directory, const QDateTime& ti m_mutex.lock(); m_files.append(info); m_matchedFiles++; + m_hotFiles++; m_mutex.unlock(); } return isEmpty; -- 2.39.5