shared: SqliteDbService: Add queryFileType()
This commit is contained in:
parent
363d207ccc
commit
71789b5b56
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user