Skip to content

Commit

Permalink
fix: The transfer of big data files is paused for about 5 minutes bef…
Browse files Browse the repository at this point in the history
…ore resuming the transfer. The system's displayed transfer speed does not match the actual speed

Modify the calculation method so that only the running status is counted as the write time

Log: The transfer of big data files is paused for about 5 minutes before resuming the transfer. The system's displayed transfer speed does not match the actual speed
Bug: https://pms.uniontech.com/bug-view-256437.html
  • Loading branch information
liyigang1 authored and max-lvs committed Jun 3, 2024
1 parent 2eaaed2 commit bd5c0bb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ void DoCopyFilesWorker::stop()

bool DoCopyFilesWorker::initArgs()
{
if (!time) {
time = new QElapsedTimer();
time->start();
if (!speedtimer) {
speedtimer = new QElapsedTimer();
speedtimer->start();
}

AbstractWorker::initArgs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ void DoCutFilesWorker::stop()

bool DoCutFilesWorker::initArgs()
{
if (!time) {
time = new QElapsedTimer();
time->start();
if (!speedtimer) {
speedtimer = new QElapsedTimer();
speedtimer->start();
}

AbstractWorker::initArgs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ void AbstractWorker::pause()
{
if (currentState == AbstractJobHandler::JobState::kPauseState)
return;
if (time) {
elapsed += time->elapsed();
delete time;
time = nullptr;
if (speedtimer) {
elapsed += speedtimer->elapsed();
delete speedtimer;
speedtimer = nullptr;
JobInfoPointer info(new QMap<quint8, QVariant>);
info->insert(AbstractJobHandler::NotifyInfoKey::kJobtypeKey, QVariant::fromValue(jobType));
info->insert(AbstractJobHandler::NotifyInfoKey::kJobStateKey, QVariant::fromValue(currentState));
Expand All @@ -139,9 +139,9 @@ void AbstractWorker::pause()
void AbstractWorker::resume()
{
setStat(AbstractJobHandler::JobState::kRunningState);
if (!time) {
time = new QElapsedTimer;
time->start();
if (!speedtimer) {
speedtimer = new QElapsedTimer;
speedtimer->start();
}

waitCondition.wakeAll();
Expand Down Expand Up @@ -613,9 +613,9 @@ AbstractWorker::~AbstractWorker()
statisticsFilesSizeJob->stop();
statisticsFilesSizeJob->wait();
}
if (time) {
delete time;
time = nullptr;
if (speedtimer) {
delete speedtimer;
speedtimer = nullptr;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <QWaitCondition>
#include <QMutex>
#include <QSharedPointer>
#include <QTime>
#include <QTimer>
#include <QThreadPool>

DPFILEOPERATIONS_BEGIN_NAMESPACE
Expand Down Expand Up @@ -185,7 +185,7 @@ protected slots:
QSharedPointer<QThreadPool> threadPool { nullptr };
static std::atomic_bool bigFileCopy;
QAtomicInteger<qint64> bigFileSize { 0 }; // bigger than this is big file
QElapsedTimer *time{ nullptr }; // time eslape
QElapsedTimer *speedtimer{ nullptr }; // time eslape
std::atomic_int64_t elapsed { 0 };
std::atomic_bool moreThanZero{ false };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ void FileOperateBaseWorker::emitSpeedUpdatedNotify(const qint64 &writSize)
{
JobInfoPointer info(new QMap<quint8, QVariant>);
qint64 elTime = 1;
if (time) {
elTime = time->elapsed() == 0 ? 1 : time->elapsed();
if (speedtimer) {
elTime = speedtimer->elapsed() == 0 ? 1 : speedtimer->elapsed();
elTime += elapsed;
}

Expand Down

0 comments on commit bd5c0bb

Please sign in to comment.