diff --git a/shared/sqlitedbservice.cpp b/shared/sqlitedbservice.cpp index adcd6c7..99f4224 100644 --- a/shared/sqlitedbservice.cpp +++ b/shared/sqlitedbservice.cpp @@ -29,6 +29,22 @@ QVector SqliteDbService::search(const LooqsQuery &query) return searcher.search(query); } +std::optional 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()); diff --git a/shared/sqlitedbservice.h b/shared/sqlitedbservice.h index 937d6b6..1c9d09d 100644 --- a/shared/sqlitedbservice.h +++ b/shared/sqlitedbservice.h @@ -1,6 +1,8 @@ #ifndef SQLITEDBSERVICE_H #define SQLITEDBSERVICE_H #include +#include + #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 search(const LooqsQuery &query); + + std::optional queryFileType(QString absPath); }; #endif // SQLITEDBSERVICE_H