summaryrefslogtreecommitdiffstats
path: root/Uploader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Uploader.cpp')
-rw-r--r--Uploader.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Uploader.cpp b/Uploader.cpp
index d915d04..dc54ed8 100644
--- a/Uploader.cpp
+++ b/Uploader.cpp
@@ -1,6 +1,7 @@
#include "Uploader.h"
#include "XorEncrypter.h"
#include <iostream>
+#include <cmath>
using namespace std;
Uploader::Uploader(const QString &ftpServer, const QString &ftpPath, const QString &username, const QString &password, const QByteArray &secretKey, const QHash<const QString, QFileInfo> &fileList, QObject *parent) :
@@ -105,10 +106,12 @@ void Uploader::uploadNextFile()
m_currentFile = new QFile(m_listPosition.value().absoluteFilePath());
m_currentFile->open(QIODevice::ReadOnly);
XorEncrypter *xorEncrypter = new XorEncrypter(m_secretKey, m_currentFile);
+ m_rateCalculator.reset();
m_latestPut = m_ftp.put(xorEncrypter, m_listPosition.key());
++m_listPosition;
}
void Uploader::dataTransferProgress(qint64 done, qint64 total)
{
- cerr << done << " of " << total << " bytes transferred.\r";
+ m_rateCalculator.updateTotalBytes(done);
+ cerr << "\r\033[2K" << static_cast<qint64>(round(done / 1024.0)) << " of " << static_cast<qint64>(round(total / 1024.0)) << " kilobytes transferred at " << static_cast<qint64>(round(m_rateCalculator.rate(10000) * 1024.0 / 1000.0)) << " kilobytes per second.";
}