Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2017-09-25 12:49:11 +0300
committerOlivier Goffart <olivier@woboq.com>2017-09-26 17:14:17 +0300
commit13e0cc6b501335c4cda9902905f503483237a46a (patch)
tree66ef6178dc05d0d7280ef0221f394a7ee8d2bfa5
parent7af81f76657aa9aed7b3942484f925b9ac9c2574 (diff)
Use QDateTime::currentDateTimeUtc instead of the non utc version
QDateTime::currentDateTime is terribly slow.
-rw-r--r--src/common/utility.cpp2
-rw-r--r--src/gui/syncrunfilelog.cpp6
-rw-r--r--src/libsync/cookiejar.cpp2
-rw-r--r--src/libsync/logger.cpp4
-rw-r--r--src/libsync/owncloudpropagator.cpp4
-rw-r--r--src/libsync/propagatedownload.cpp2
-rw-r--r--src/libsync/propagateupload.cpp2
-rw-r--r--src/libsync/syncengine.cpp2
-rw-r--r--src/libsync/syncresult.cpp2
-rw-r--r--test/mockserver/httpserver.cpp2
-rw-r--r--test/syncenginetestutils.h4
-rw-r--r--test/testsyncengine.cpp8
12 files changed, 20 insertions, 20 deletions
diff --git a/src/common/utility.cpp b/src/common/utility.cpp
index 460435f1d..212433c75 100644
--- a/src/common/utility.cpp
+++ b/src/common/utility.cpp
@@ -465,7 +465,7 @@ static const char STOPWATCH_END_TAG[] = "_STOPWATCH_END";
void Utility::StopWatch::start()
{
- _startTime = QDateTime::currentDateTime();
+ _startTime = QDateTime::currentDateTimeUtc();
_timer.start();
}
diff --git a/src/gui/syncrunfilelog.cpp b/src/gui/syncrunfilelog.cpp
index 51396cbb0..9d4a06d7f 100644
--- a/src/gui/syncrunfilelog.cpp
+++ b/src/gui/syncrunfilelog.cpp
@@ -127,7 +127,7 @@ void SyncRunFileLog::start(const QString &folderPath)
_totalDuration.start();
_lapDuration.start();
- _out << "#=#=#=# Syncrun started " << dateTimeStr(QDateTime::currentDateTime()) << endl;
+ _out << "#=#=#=# Syncrun started " << dateTimeStr(QDateTime::currentDateTimeUtc()) << endl;
}
void SyncRunFileLog::logItem(const SyncFileItem &item)
@@ -172,14 +172,14 @@ void SyncRunFileLog::logItem(const SyncFileItem &item)
void SyncRunFileLog::logLap(const QString &name)
{
- _out << "#=#=#=#=# " << name << " " << dateTimeStr(QDateTime::currentDateTime())
+ _out << "#=#=#=#=# " << name << " " << dateTimeStr(QDateTime::currentDateTimeUtc())
<< " (last step: " << _lapDuration.restart() << " msec"
<< ", total: " << _totalDuration.elapsed() << " msec)" << endl;
}
void SyncRunFileLog::finish()
{
- _out << "#=#=#=# Syncrun finished " << dateTimeStr(QDateTime::currentDateTime())
+ _out << "#=#=#=# Syncrun finished " << dateTimeStr(QDateTime::currentDateTimeUtc())
<< " (last step: " << _lapDuration.elapsed() << " msec"
<< ", total: " << _totalDuration.elapsed() << " msec)" << endl;
_file->close();
diff --git a/src/libsync/cookiejar.cpp b/src/libsync/cookiejar.cpp
index 4af34d5e7..a15ac87d1 100644
--- a/src/libsync/cookiejar.cpp
+++ b/src/libsync/cookiejar.cpp
@@ -124,7 +124,7 @@ QList<QNetworkCookie> CookieJar::removeExpired(const QList<QNetworkCookie> &cook
{
QList<QNetworkCookie> updatedList;
foreach (const QNetworkCookie &cookie, cookies) {
- if (cookie.expirationDate() > QDateTime::currentDateTime() && !cookie.isSessionCookie()) {
+ if (cookie.expirationDate() > QDateTime::currentDateTimeUtc() && !cookie.isSessionCookie()) {
updatedList << cookie;
}
}
diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp
index a0fe727e8..31afbbe8c 100644
--- a/src/libsync/logger.cpp
+++ b/src/libsync/logger.cpp
@@ -152,7 +152,7 @@ void Logger::mirallLog(const QString &message)
{
Log log_;
log_.source = Log::Occ;
- log_.timeStamp = QDateTime::currentDateTime();
+ log_.timeStamp = QDateTime::currentDateTimeUtc();
log_.message = message;
Logger::instance()->log(log_);
@@ -236,7 +236,7 @@ void Logger::enterNextLogFile()
QDir::Files);
QRegExp rx("owncloud.log.(\\d+)");
uint maxNumber = 0;
- QDateTime now = QDateTime::currentDateTime();
+ QDateTime now = QDateTime::currentDateTimeUtc();
foreach (const QString &s, files) {
if (rx.exactMatch(s)) {
maxNumber = qMax(maxNumber, rx.cap(1).toUInt());
diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp
index 4673e9b34..281f34548 100644
--- a/src/libsync/owncloudpropagator.cpp
+++ b/src/libsync/owncloudpropagator.cpp
@@ -138,7 +138,7 @@ static SyncJournalErrorBlacklistRecord createBlacklistEntry(
entry._errorString = item._errorString;
entry._lastTryModtime = item._modtime;
entry._lastTryEtag = item._etag;
- entry._lastTryTime = Utility::qDateTimeToTime_t(QDateTime::currentDateTime());
+ entry._lastTryTime = Utility::qDateTimeToTime_t(QDateTime::currentDateTimeUtc());
entry._renameTarget = item._renameTarget;
entry._retryCount = old._retryCount + 1;
@@ -309,7 +309,7 @@ bool PropagateItemJob::checkForProblemsWithShared(int httpStatusCode, const QStr
// HACK to avoid continuation: See task #1448: We do not know the _modtime from the
// server, at this point, so just set the current one. (rather than the one locally)
- downloadItem->_modtime = Utility::qDateTimeToTime_t(QDateTime::currentDateTime());
+ downloadItem->_modtime = Utility::qDateTimeToTime_t(QDateTime::currentDateTimeUtc());
} else {
// the file was removed or renamed, just recover the old one
downloadItem->_instruction = CSYNC_INSTRUCTION_SYNC;
diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp
index 6466d13b6..11207d2ad 100644
--- a/src/libsync/propagatedownload.cpp
+++ b/src/libsync/propagatedownload.cpp
@@ -673,7 +673,7 @@ namespace { // Anonymous namespace for the recall feature
dotLocation = recallFileName.size();
}
- QString timeString = QDateTime::currentDateTime().toString("yyyyMMdd-hhmmss");
+ QString timeString = QDateTime::currentDateTimeUtc().toString("yyyyMMdd-hhmmss");
recallFileName.insert(dotLocation, "_.sys.admin#recall#-" + timeString);
return recallFileName;
diff --git a/src/libsync/propagateupload.cpp b/src/libsync/propagateupload.cpp
index 5ba8a5c6b..eca042678 100644
--- a/src/libsync/propagateupload.cpp
+++ b/src/libsync/propagateupload.cpp
@@ -53,7 +53,7 @@ Q_LOGGING_CATEGORY(lcPropagateUpload, "sync.propagator.upload", QtInfoMsg)
static bool fileIsStillChanging(const SyncFileItem &item)
{
const QDateTime modtime = Utility::qDateTimeFromTime_t(item._modtime);
- const qint64 msSinceMod = modtime.msecsTo(QDateTime::currentDateTime());
+ const qint64 msSinceMod = modtime.msecsTo(QDateTime::currentDateTimeUtc());
return msSinceMod < SyncEngine::minimumFileAgeForUpload
// if the mtime is too much in the future we *do* upload the file
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 2c71ae734..80d36d4be 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -219,7 +219,7 @@ bool SyncEngine::checkErrorBlacklisting(SyncFileItem &item)
item._hasBlacklistEntry = true;
// If duration has expired, it's not blacklisted anymore
- time_t now = Utility::qDateTimeToTime_t(QDateTime::currentDateTime());
+ time_t now = Utility::qDateTimeToTime_t(QDateTime::currentDateTimeUtc());
if (now >= entry._lastTryTime + entry._ignoreDuration) {
qCInfo(lcEngine) << "blacklist entry for " << item._file << " has expired!";
return false;
diff --git a/src/libsync/syncresult.cpp b/src/libsync/syncresult.cpp
index 52ce018d1..c2aeb24ed 100644
--- a/src/libsync/syncresult.cpp
+++ b/src/libsync/syncresult.cpp
@@ -85,7 +85,7 @@ QString SyncResult::statusString() const
void SyncResult::setStatus(Status stat)
{
_status = stat;
- _syncTime = QDateTime::currentDateTime();
+ _syncTime = QDateTime::currentDateTimeUtc();
}
QDateTime SyncResult::syncTime() const
diff --git a/test/mockserver/httpserver.cpp b/test/mockserver/httpserver.cpp
index c1f2a0cee..fbc24e847 100644
--- a/test/mockserver/httpserver.cpp
+++ b/test/mockserver/httpserver.cpp
@@ -32,7 +32,7 @@ void HttpServer::readClient()
"Content-Type: text/html; charset=\"utf-8\"\r\n"
"\r\n"
"<h1>Nothing to see here</h1>\n"
- << QDateTime::currentDateTime().toString() << "\n";
+ << QDateTime::currentDateTimeUtc().toString() << "\n";
socket->close();
QtServiceBase::instance()->logMessage("Wrote to client");
diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h
index cabac73bf..9253b6285 100644
--- a/test/syncenginetestutils.h
+++ b/test/syncenginetestutils.h
@@ -41,7 +41,7 @@ inline QString getFilePathFromUrl(const QUrl &url) {
inline QString generateEtag() {
- return QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch(), 16);
+ return QString::number(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch(), 16);
}
inline QByteArray generateFileId() {
return QByteArray::number(qrand(), 16);
@@ -97,7 +97,7 @@ public:
file.write(buf.data(), size % buf.size());
file.close();
// Set the mtime 30 seconds in the past, for some tests that need to make sure that the mtime differs.
- OCC::FileSystem::setModTime(file.fileName(), OCC::Utility::qDateTimeToTime_t(QDateTime::currentDateTime().addSecs(-30)));
+ OCC::FileSystem::setModTime(file.fileName(), OCC::Utility::qDateTimeToTime_t(QDateTime::currentDateTimeUtc().addSecs(-30)));
QCOMPARE(file.size(), size);
}
void setContents(const QString &relativePath, char contentChar) override {
diff --git a/test/testsyncengine.cpp b/test/testsyncengine.cpp
index a4c4c5be4..169c2e6fb 100644
--- a/test/testsyncengine.cpp
+++ b/test/testsyncengine.cpp
@@ -358,7 +358,7 @@ private slots:
FileInfo &remoteInfo = dynamic_cast<FileInfo &>(fakeFolder.remoteModifier());
// Base mtime with no ms content (filesystem is seconds only)
- auto mtime = QDateTime::currentDateTime().addDays(-4);
+ auto mtime = QDateTime::currentDateTimeUtc().addDays(-4);
mtime.setMSecsSinceEpoch(mtime.toMSecsSinceEpoch() / 1000 * 1000);
// Conflict: Same content, mtime, but no server checksum
@@ -414,9 +414,9 @@ private slots:
*/
void testSyncFileItemProperties()
{
- auto initialMtime = QDateTime::currentDateTime().addDays(-7);
- auto changedMtime = QDateTime::currentDateTime().addDays(-4);
- auto changedMtime2 = QDateTime::currentDateTime().addDays(-3);
+ auto initialMtime = QDateTime::currentDateTimeUtc().addDays(-7);
+ auto changedMtime = QDateTime::currentDateTimeUtc().addDays(-4);
+ auto changedMtime2 = QDateTime::currentDateTimeUtc().addDays(-3);
// Base mtime with no ms content (filesystem is seconds only)
initialMtime.setMSecsSinceEpoch(initialMtime.toMSecsSinceEpoch() / 1000 * 1000);