File indexing completed on 2024-04-21 03:51:44

0001 /*
0002     SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #include "filecontentindexerprovider.h"
0008 
0009 #include "transaction.h"
0010 #include "database.h"
0011 
0012 using namespace Baloo;
0013 
0014 FileContentIndexerProvider::FileContentIndexerProvider(Database* db)
0015     : m_db(db)
0016 {
0017 }
0018 
0019 QVector<quint64> FileContentIndexerProvider::fetch(uint size)
0020 {
0021     Transaction tr(m_db, Transaction::ReadOnly);
0022     return tr.fetchPhaseOneIds(size);
0023 }
0024 
0025 uint FileContentIndexerProvider::size()
0026 {
0027     Transaction tr(m_db, Transaction::ReadOnly);
0028     return tr.phaseOneSize();
0029 }
0030 
0031 bool FileContentIndexerProvider::markFailed(quint64 id)
0032 {
0033     Transaction tr(m_db, Transaction::ReadWrite);
0034     if (!tr.hasFailed(id)) {
0035         tr.addFailed(id);
0036     }
0037     tr.removePhaseOne(id);
0038     return tr.commit();
0039 }