shared: SqliteDbService: Add queryFileType()

这个提交包含在:
Albert S. 2023-01-08 17:37:28 +01:00
父节点 363d207ccc
当前提交 71789b5b56
共有 2 个文件被更改,包括 20 次插入0 次删除

查看文件

@ -29,6 +29,22 @@ QVector<SearchResult> SqliteDbService::search(const LooqsQuery &query)
return searcher.search(query);
}
std::optional<QChar> SqliteDbService::queryFileType(QString 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 {};
}
return query.value(0).toChar();
}
bool SqliteDbService::fileExistsInDatabase(QString path)
{
auto query = QSqlQuery(dbFactory->forCurrentThread());

查看文件

@ -1,6 +1,8 @@
#ifndef SQLITEDBSERVICE_H
#define SQLITEDBSERVICE_H
#include <QFileInfo>
#include <optional>
#include "databasefactory.h"
#include "utils.h"
#include "pagedata.h"
@ -23,6 +25,8 @@ class SqliteDbService
bool fileExistsInDatabase(QString path);
bool fileExistsInDatabase(QString path, qint64 mtime);
QVector<SearchResult> search(const LooqsQuery &query);
std::optional<QChar> queryFileType(QString absPath);
};
#endif // SQLITEDBSERVICE_H