From kde-commits Sun Sep 11 16:52:23 2016 From: Christoph Cullmann Date: Sun, 11 Sep 2016 16:52:23 +0000 To: kde-commits Subject: [baloo] /: allow ctime/mtime == 0 Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=147361275232353 Git commit 628daced19b88d0c537736a14aea3287a4662609 by Christoph Cullmann. Committed on 11/09/2016 at 16:48. Pushed by cullmann into branch 'master'. allow ctime/mtime =3D=3D 0 Fix that baloo is instant killed by any file with timestamp 0. (which is OK= and can easily happen after unpacking some zip/tar/..) REVIEW: 128887 BUG: 355238 M +17 -0 autotests/unit/engine/documenttimedbtest.cpp M +0 -2 src/engine/documenttimedb.cpp M +0 -3 src/engine/writetransaction.cpp http://commits.kde.org/baloo/628daced19b88d0c537736a14aea3287a4662609 diff --git a/autotests/unit/engine/documenttimedbtest.cpp b/autotests/unit/= engine/documenttimedbtest.cpp index 18231bf..c509e5c 100644 --- a/autotests/unit/engine/documenttimedbtest.cpp +++ b/autotests/unit/engine/documenttimedbtest.cpp @@ -28,6 +28,7 @@ class DocumentTimeDBTest : public SingleDBTest Q_OBJECT private Q_SLOTS: void test(); + void testAllowZeroTime(); }; = void DocumentTimeDBTest::test() @@ -45,6 +46,22 @@ void DocumentTimeDBTest::test() QCOMPARE(db.get(1), DocumentTimeDB::TimeInfo()); } = +void DocumentTimeDBTest::testAllowZeroTime() +{ + DocumentTimeDB db(DocumentTimeDB::create(m_txn), m_txn); + + // we must be able to handle zero time, aka 1970... + DocumentTimeDB::TimeInfo info; + info.mTime =3D 0; + info.cTime =3D 0; + + db.put(1, info); + QCOMPARE(db.get(1), info); + + db.del(1); + QCOMPARE(db.get(1), DocumentTimeDB::TimeInfo()); +} + QTEST_MAIN(DocumentTimeDBTest) = #include "documenttimedbtest.moc" diff --git a/src/engine/documenttimedb.cpp b/src/engine/documenttimedb.cpp index aa0925a..ef744b9 100644 --- a/src/engine/documenttimedb.cpp +++ b/src/engine/documenttimedb.cpp @@ -58,8 +58,6 @@ MDB_dbi DocumentTimeDB::open(MDB_txn* txn) void DocumentTimeDB::put(quint64 docId, const TimeInfo& info) { Q_ASSERT(docId > 0); - Q_ASSERT(info.mTime); - Q_ASSERT(info.cTime); = MDB_val key; key.mv_size =3D sizeof(quint64); diff --git a/src/engine/writetransaction.cpp b/src/engine/writetransaction.= cpp index 9ad7520..3808970 100644 --- a/src/engine/writetransaction.cpp +++ b/src/engine/writetransaction.cpp @@ -206,9 +206,6 @@ void WriteTransaction::replaceDocument(const Document& = doc, DocumentOperations o } = if (operations & DocumentTime) { - Q_ASSERT(doc.m_mTime); - Q_ASSERT(doc.m_cTime); - DocumentTimeDB::TimeInfo info; info.mTime =3D doc.m_mTime; info.cTime =3D doc.m_cTime;