QDateTime::currentDateTime is terribly slow.
void Utility::StopWatch::start()
{
- _startTime = QDateTime::currentDateTime();
+ _startTime = QDateTime::currentDateTimeUtc();
_timer.start();
}
_totalDuration.start();
_lapDuration.start();
- _out << "#=#=#=# Syncrun started " << dateTimeStr(QDateTime::currentDateTime()) << endl;
+ _out << "#=#=#=# Syncrun started " << dateTimeStr(QDateTime::currentDateTimeUtc()) << endl;
}
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();
{
QList<QNetworkCookie> updatedList;
foreach (const QNetworkCookie &cookie, cookies) {
- if (cookie.expirationDate() > QDateTime::currentDateTime() && !cookie.isSessionCookie()) {
+ if (cookie.expirationDate() > QDateTime::currentDateTimeUtc() && !cookie.isSessionCookie()) {
updatedList << cookie;
}
}
{
Log log_;
log_.source = Log::Occ;
- log_.timeStamp = QDateTime::currentDateTime();
+ log_.timeStamp = QDateTime::currentDateTimeUtc();
log_.message = message;
Logger::instance()->log(log_);
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());
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;
// 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;
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;
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
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;
void SyncResult::setStatus(Status stat)
{
_status = stat;
- _syncTime = QDateTime::currentDateTime();
+ _syncTime = QDateTime::currentDateTimeUtc();
}
QDateTime SyncResult::syncTime() const
"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");
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);
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 {
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
*/
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);