Commit a9437332 authored by Martin Koller's avatar Martin Koller

always use UTC timestamp for PimItem datetime and atime

Differential Revision: https://phabricator.kde.org/D5672
parent 273116ad
......@@ -122,7 +122,7 @@ void CacheCleaner::collectionExpired(const Collection &collection)
qb.addJoin(QueryBuilder::InnerJoin, PimItem::tableName(), Part::pimItemIdColumn(), PimItem::idFullColumnName());
qb.addJoin(QueryBuilder::InnerJoin, PartType::tableName(), Part::partTypeIdFullColumnName(), PartType::idFullColumnName());
qb.addValueCondition(PimItem::collectionIdFullColumnName(), Query::Equals, collection.id());
qb.addValueCondition(PimItem::atimeFullColumnName(), Query::Less, QDateTime::currentDateTime().addSecs(-60 * collection.cachePolicyCacheTimeout()));
qb.addValueCondition(PimItem::atimeFullColumnName(), Query::Less, QDateTime::currentDateTimeUtc().addSecs(-60 * collection.cachePolicyCacheTimeout()));
qb.addValueCondition(Part::dataFullColumnName(), Query::IsNot, QVariant());
qb.addValueCondition(PartType::nsFullColumnName(), Query::Equals, QLatin1String("PLD"));
qb.addValueCondition(PimItem::dirtyFullColumnName(), Query::Equals, false);
......
......@@ -74,7 +74,7 @@ bool AkAppend::buildPimItem(const Protocol::CreateItemCommand &cmd, PimItem &ite
}
item.setRemoteRevision(cmd.remoteRevision());
item.setGid(cmd.gid());
item.setAtime(QDateTime::currentDateTime());
item.setAtime(QDateTime::currentDateTimeUtc());
return true;
}
......@@ -284,7 +284,7 @@ bool AkAppend::mergeItem(const Protocol::CreateItemCommand &cmd,
if (needsUpdate) {
currentItem.setRev(qMax(newItem.rev(), currentItem.rev()) + 1);
currentItem.setAtime(QDateTime::currentDateTime());
currentItem.setAtime(QDateTime::currentDateTimeUtc());
// Only mark dirty when merged from application
currentItem.setDirty(!connection()->context()->resource().isValid());
......
......@@ -39,8 +39,8 @@ bool Copy::copyItem(const PimItem &item, const Collection &target)
PimItem newItem = item;
newItem.setId(-1);
newItem.setRev(0);
newItem.setDatetime(QDateTime::currentDateTime());
newItem.setAtime(QDateTime::currentDateTime());
newItem.setDatetime(QDateTime::currentDateTimeUtc());
newItem.setAtime(QDateTime::currentDateTimeUtc());
newItem.setRemoteId(QString());
newItem.setRemoteRevision(QString());
newItem.setCollectionId(target.id());
......@@ -55,7 +55,7 @@ bool Copy::copyItem(const PimItem &item, const Collection &target)
}
DataStore *store = connection()->storageBackend();
if (!store->appendPimItem(parts, item.flags(), item.mimeType(), target, QDateTime::currentDateTime(), QString(), QString(), item.gid(), newItem)) {
if (!store->appendPimItem(parts, item.flags(), item.mimeType(), target, QDateTime::currentDateTimeUtc(), QString(), QString(), item.gid(), newItem)) {
return false;
}
......
......@@ -41,7 +41,7 @@ void Move::itemsRetrieved(const QList<qint64> &ids)
ItemQueryHelper::itemSetToQuery(ImapSet(ids), qb);
qb.addValueCondition(PimItem::collectionIdFullColumnName(), Query::NotEquals, mDestination.id());
const QDateTime mtime = QDateTime::currentDateTime();
const QDateTime mtime = QDateTime::currentDateTimeUtc();
if (!qb.exec()) {
failureResponse("Unable to execute query");
......
......@@ -130,10 +130,10 @@
<column name="gid" type="QString"/>
<column name="collectionId" type="qint64" refTable="Collection" refColumn="id"/>
<column name="mimeTypeId" type="qint64" refTable="MimeType" refColumn="id" onDelete="Restrict"/>
<column name="datetime" type="QDateTime" default="QDateTime::currentDateTime()">
<column name="datetime" type="QDateTime" default="QDateTime::currentDateTimeUtc()">
<comment>create/modified time</comment>
</column>
<column name="atime" type="QDateTime" default="QDateTime::currentDateTime()">
<column name="atime" type="QDateTime" default="QDateTime::currentDateTimeUtc()">
<comment>read access time</comment>
</column>
<column name="dirty" type="bool">
......
......@@ -872,7 +872,7 @@ static bool recursiveSetResourceId(const Collection &collection, qint64 resource
qb.addValueCondition(PimItem::collectionIdColumn(), Query::Equals, collection.id());
qb.setColumnValue(PimItem::remoteIdColumn(), QVariant());
qb.setColumnValue(PimItem::remoteRevisionColumn(), QVariant());
const QDateTime now = QDateTime::currentDateTime();
const QDateTime now = QDateTime::currentDateTimeUtc();
qb.setColumnValue(PimItem::datetimeColumn(), now);
qb.setColumnValue(PimItem::atimeColumn(), now);
qb.setColumnValue(PimItem::dirtyColumn(), true);
......@@ -1065,7 +1065,7 @@ bool DataStore::appendPimItem(QVector<Part> &parts,
}
pimItem.setRemoteRevision(remoteRevision);
pimItem.setGid(gid);
pimItem.setAtime(QDateTime::currentDateTime());
pimItem.setAtime(QDateTime::currentDateTimeUtc());
if (!pimItem.insert()) {
return false;
......
......@@ -314,7 +314,7 @@ QString DbInitializer::sqlType(const ColumnDescription &col, int size) const
QString DbInitializer::sqlValue(const ColumnDescription &col, const QString &value) const
{
if (col.type == QLatin1String("QDateTime") && value == QLatin1String("QDateTime::currentDateTime()")) {
if (col.type == QLatin1String("QDateTime") && value == QLatin1String("QDateTime::currentDateTimeUtc()")) {
return QStringLiteral("CURRENT_TIMESTAMP");
} else if (col.isEnum) {
return QString::number(col.enumValueMap[value]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment