~aleteoryx/muditaos

ca7de85fef97bb33c2158547dd38e60da7da2ae9 — Bartosz 3 years ago 9744d39
[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
M module-services/service-fileindexer/CMakeLists.txt => module-services/service-fileindexer/CMakeLists.txt +2 -1
@@ 29,6 29,7 @@ target_link_libraries(service-fileindexer
		module-os 
		module-utils 
		module-vfs 
		module-sys 
		module-sys
		module-db
		tag
)

M module-services/service-fileindexer/StartupIndexer.cpp => module-services/service-fileindexer/StartupIndexer.cpp +6 -2
@@ 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;