Vergelijk commits
No commits in common. "a9d3f7897ab63c0ce956703afcb658ccb5692a05" and "0b829215e5aa05680c99c19468db8f02db969bc5" have entirely different histories.
a9d3f7897a
...
0b829215e5
@ -421,22 +421,16 @@
|
||||
<property name="text">
|
||||
<string>Index everything (metadata + file content)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="chkFillContentForContentless">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Index content for files previously indexed without content</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -5,6 +5,22 @@
|
||||
#include "sqlitedbservice.h"
|
||||
#include "filedata.h"
|
||||
#include "logger.h"
|
||||
bool SqliteDbService::fileExistsInDatabase(QString path, qint64 mtime)
|
||||
{
|
||||
auto query = QSqlQuery(dbFactory->forCurrentThread());
|
||||
query.prepare("SELECT 1 FROM file WHERE path = ? and mtime = ?");
|
||||
query.addBindValue(path);
|
||||
query.addBindValue(mtime);
|
||||
if(!query.exec())
|
||||
{
|
||||
throw LooqsGeneralException("Error while trying to query for file existance: " + query.lastError().text());
|
||||
}
|
||||
if(!query.next())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return query.value(0).toBool();
|
||||
}
|
||||
|
||||
QVector<SearchResult> SqliteDbService::search(const LooqsQuery &query)
|
||||
{
|
||||
@ -15,7 +31,13 @@ QVector<SearchResult> SqliteDbService::search(const LooqsQuery &query)
|
||||
|
||||
std::optional<QChar> SqliteDbService::queryFileType(QString absPath)
|
||||
{
|
||||
auto query = exec("SELCET filetype FROM file WHERE path = ?", {absPath});
|
||||
auto query = QSqlQuery(dbFactory->forCurrentThread());
|
||||
query.prepare("SELECT filetype FROM file WHERE path = ?");
|
||||
query.addBindValue(absPath);
|
||||
if(!query.exec())
|
||||
{
|
||||
throw LooqsGeneralException("Error while trying to query for file type: " + query.lastError().text());
|
||||
}
|
||||
if(!query.next())
|
||||
{
|
||||
return {};
|
||||
@ -25,17 +47,18 @@ std::optional<QChar> SqliteDbService::queryFileType(QString absPath)
|
||||
|
||||
bool SqliteDbService::fileExistsInDatabase(QString path)
|
||||
{
|
||||
return execBool("SELECT 1 FROM file WHERE path = ?", {path});
|
||||
}
|
||||
|
||||
bool SqliteDbService::fileExistsInDatabase(QString path, qint64 mtime)
|
||||
{
|
||||
return execBool("SELECT 1 FROM file WHERE path = ? AND mtime = ?", {path, mtime});
|
||||
}
|
||||
|
||||
bool SqliteDbService::fileExistsInDatabase(QString path, qint64 mtime, QChar fileType)
|
||||
{
|
||||
return execBool("SELECT 1 FROM file WHERE path = ? AND mtime = ? AND filetype = ?", {path, mtime, fileType});
|
||||
auto query = QSqlQuery(dbFactory->forCurrentThread());
|
||||
query.prepare("SELECT 1 FROM file WHERE path = ?");
|
||||
query.addBindValue(path);
|
||||
if(!query.exec())
|
||||
{
|
||||
throw LooqsGeneralException("Error while trying to query for file existance: " + query.lastError().text());
|
||||
}
|
||||
if(!query.next())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return query.value(0).toBool();
|
||||
}
|
||||
|
||||
SqliteDbService::SqliteDbService(DatabaseFactory &dbFactory)
|
||||
@ -141,31 +164,6 @@ bool SqliteDbService::insertToFTS(bool useTrigrams, QSqlDatabase &db, int fileid
|
||||
return true;
|
||||
}
|
||||
|
||||
QSqlQuery SqliteDbService::exec(QString querystr, std::initializer_list<QVariant> args)
|
||||
{
|
||||
auto query = QSqlQuery(dbFactory->forCurrentThread());
|
||||
query.prepare(querystr);
|
||||
for(const QVariant &v : args)
|
||||
{
|
||||
query.addBindValue(v);
|
||||
}
|
||||
if(!query.exec())
|
||||
{
|
||||
throw LooqsGeneralException("Error while trying to query for file existance: " + query.lastError().text());
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
bool SqliteDbService::execBool(QString querystr, std::initializer_list<QVariant> args)
|
||||
{
|
||||
auto query = exec(querystr, args);
|
||||
if(!query.next())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return query.value(0).toBool();
|
||||
}
|
||||
|
||||
SaveFileResult SqliteDbService::saveFile(QFileInfo fileInfo, QVector<PageData> &pageData, bool pathsOnly)
|
||||
{
|
||||
QString absPath = fileInfo.absoluteFilePath();
|
||||
|
@ -17,9 +17,6 @@ class SqliteDbService
|
||||
DatabaseFactory *dbFactory = nullptr;
|
||||
bool insertToFTS(bool useTrigrams, QSqlDatabase &db, int fileid, QVector<PageData> &pageData);
|
||||
|
||||
QSqlQuery exec(QString query, std::initializer_list<QVariant> args);
|
||||
bool execBool(QString querystr, std::initializer_list<QVariant> args);
|
||||
|
||||
public:
|
||||
SqliteDbService(DatabaseFactory &dbFactory);
|
||||
SaveFileResult saveFile(QFileInfo fileInfo, QVector<PageData> &pageData, bool pathsOnly);
|
||||
@ -27,7 +24,6 @@ class SqliteDbService
|
||||
bool deleteFile(QString path);
|
||||
bool fileExistsInDatabase(QString path);
|
||||
bool fileExistsInDatabase(QString path, qint64 mtime);
|
||||
bool fileExistsInDatabase(QString path, qint64 mtime, QChar filetype);
|
||||
QVector<SearchResult> search(const LooqsQuery &query);
|
||||
|
||||
std::optional<QChar> queryFileType(QString absPath);
|
||||
|
Laden…
Verwijs in nieuw issue
Block a user