[kio] src/core: Revert "Don't stat(/etc/localtime) between read() and write() copying files"
Fabian Vogt
null at kde.org
Mon Jan 15 11:33:24 UTC 2018
Git commit 16b21e7223f5bc070dcfd540ede55e5837ccc097 by Fabian Vogt.
Committed on 15/01/2018 at 11:31.
Pushed by fvogt into branch 'master'.
Revert "Don't stat(/etc/localtime) between read() and write() copying files"
This reverts commit f7e00b40a6d35fbfe536cdb99d6f22b643676e5e.
This results in calling special() without the ioslave's consent, breaking
at least the trash and desktop ioslaves.
CCMAIL: jtamate at gmail.com
CCMAIL: kde-frameworks-devel at kde.org
M +12 -13 src/core/slavebase.cpp
https://commits.kde.org/kio/16b21e7223f5bc070dcfd540ede55e5837ccc097
diff --git a/src/core/slavebase.cpp b/src/core/slavebase.cpp
index b0625a51..4f8a5dad 100644
--- a/src/core/slavebase.cpp
+++ b/src/core/slavebase.cpp
@@ -86,8 +86,6 @@ public:
QStandardPaths::enableTestMode(true);
}
pendingListEntries.reserve(KIO_MAX_ENTRIES_PER_BATCH);
- lastTimeout.start();
- nextTimeout.start();
}
~SlaveBasePrivate()
{
@@ -112,9 +110,8 @@ public:
KConfigGroup *configGroup;
QUrl onHoldUrl;
- QElapsedTimer lastTimeout;
- QElapsedTimer nextTimeout;
- qint64 nextTimeoutMsecs;
+ QDateTime lastTimeout;
+ QDateTime nextTimeout;
KIO::filesize_t totalSize;
KRemoteEncoding *remotefile;
enum { Idle, InsideMethod, FinishedCalled, ErrorCalled } m_state;
@@ -276,9 +273,9 @@ SlaveBase::~SlaveBase()
void SlaveBase::dispatchLoop()
{
while (!d->exit_loop) {
- if (d->nextTimeout.isValid() && (d->nextTimeout.hasExpired(d->nextTimeoutMsecs))) {
+ if (d->nextTimeout.isValid() && (d->nextTimeout < QDateTime::currentDateTime())) {
QByteArray data = d->timeoutData;
- d->nextTimeout.restart();
+ d->nextTimeout = QDateTime();
d->timeoutData = QByteArray();
special(data);
}
@@ -287,7 +284,7 @@ void SlaveBase::dispatchLoop()
int ms = -1;
if (d->nextTimeout.isValid()) {
- ms = qMax<int>(d->nextTimeout.elapsed() - d->nextTimeoutMsecs, 1);
+ ms = qMax<int>(QDateTime::currentDateTime().msecsTo(d->nextTimeout), 1);
}
int ret = -1;
@@ -532,11 +529,13 @@ void SlaveBase::processedSize(KIO::filesize_t _bytes)
{
bool emitSignal = false;
+ QDateTime now = QDateTime::currentDateTime();
+
if (_bytes == d->totalSize) {
emitSignal = true;
} else {
if (d->lastTimeout.isValid()) {
- emitSignal = d->lastTimeout.hasExpired(100); // emit size 10 times a second
+ emitSignal = d->lastTimeout.msecsTo(now) >= 100; // emit size 10 times a second
} else {
emitSignal = true;
}
@@ -545,7 +544,7 @@ void SlaveBase::processedSize(KIO::filesize_t _bytes)
if (emitSignal) {
KIO_DATA << KIO_FILESIZE_T(_bytes);
send(INF_PROCESSED_SIZE, data);
- d->lastTimeout.restart();
+ d->lastTimeout = now;
}
// d->processed_size = _bytes;
@@ -1047,11 +1046,11 @@ int SlaveBase::readData(QByteArray &buffer)
void SlaveBase::setTimeoutSpecialCommand(int timeout, const QByteArray &data)
{
if (timeout > 0) {
- d->nextTimeoutMsecs = timeout*1000; // from seconds to miliseconds
+ d->nextTimeout = QDateTime::currentDateTime().addSecs(timeout);
} else if (timeout == 0) {
- d->nextTimeoutMsecs = 1000;
+ d->nextTimeout = QDateTime::currentDateTime().addSecs(1); // Immediate timeout
} else {
- d->nextTimeoutMsecs = 1;
+ d->nextTimeout = QDateTime(); // Canceled
}
d->timeoutData = data;
More information about the Kde-frameworks-devel
mailing list