File 0003-allow-ctime-mtime-0.patch of Package baloo5

From 628daced19b88d0c537736a14aea3287a4662609 Mon Sep 17 00:00:00 2001
From: Christoph Cullmann <cullmann@kde.org>
Date: Sun, 11 Sep 2016 18:48:53 +0200
Subject: [PATCH 03/13] allow ctime/mtime == 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
---
 autotests/unit/engine/documenttimedbtest.cpp | 17 +++++++++++++++++
 src/engine/documenttimedb.cpp                |  2 --
 src/engine/writetransaction.cpp              |  3 ---
 3 files changed, 17 insertions(+), 5 deletions(-)

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 = 0;
+    info.cTime = 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 = 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 = doc.m_mTime;
         info.cTime = doc.m_cTime;
-- 
2.10.0