[MOS-853] Purge multimedia database when initializing indexer

When startup indexer for FileIndexer starts, it checks for
lock file. If it's not present, it starts the indexing.

Due to changes in DB initialization we have to purge the
DB before starting the init scan because of potential
restore content
This commit is contained in:
Bartosz
2022-12-28 15:11:47 +01:00
committed by Bartosz Cichocki
parent 9744d39137
commit ca7de85fef
2 changed files with 8 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ target_link_libraries(service-fileindexer
module-os
module-utils
module-vfs
module-sys
module-sys
module-db
tag
)

View File

@@ -10,9 +10,9 @@
#include <purefs/fs/inotify_message.hpp>
#include <log/log.hpp>
#include <filesystem>
#include <fstream>
#include <optional>
#include <queries/multimedia_files/QueryMultimediaFilesRemove.hpp>
#include <service-db/DBServiceAPI.hpp>
namespace service::detail
{
@@ -126,6 +126,10 @@ namespace service::detail
{
if (!hasLockFile()) {
LOG_INFO("Initial startup indexer - Started...");
auto query = std::make_unique<db::multimedia_files::query::RemoveAll>();
DBServiceAPI::GetQuery(svc.get(), db::Interface::Name::MultimediaFiles, std::move(query));
mTopDirIterator = std::begin(directoriesToScan);
setupTimers(svc, svc_name);
mForceStop = false;