Commit cfad5074 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Let the MediaLibrary populates its own discoverers

parent 139bc49e
......@@ -73,7 +73,6 @@ class IMediaLibrary : public IDiscovererCb
virtual void addMetadataService( std::unique_ptr<IMetadataService> service ) = 0;
virtual void parse( FilePtr file, IParserCb* cb ) = 0;
virtual void addDiscoverer( std::unique_ptr<IDiscoverer> discoverer ) = 0;
/**
* @brief discover Launch a discovery on the provided entry point.
* There no garanty on how this will be processed, or if it will be processed synchronously or not.
......
......@@ -16,6 +16,9 @@
#include "Utils.h"
#include "VideoTrack.h"
// Discoverers:
#include "discoverer/FsDiscoverer.h"
#include "filesystem/IDirectory.h"
#include "filesystem/IFile.h"
#include "factory/FileSystem.h"
......@@ -64,6 +67,8 @@ bool MediaLibrary::initialize( const std::string& dbPath, const std::string& sna
m_fsFactory.reset( new factory::FileSystemDefaultFactory );
m_snapshotPath = snapshotPath;
m_discoverers.emplace_back( new FsDiscoverer( m_fsFactory, this ) );
sqlite3* dbConnection;
int res = sqlite3_open( dbPath.c_str(), &dbConnection );
if ( res != SQLITE_OK )
......@@ -197,11 +202,6 @@ void MediaLibrary::parse(FilePtr file , IParserCb* cb)
m_parser->parse( file, cb );
}
void MediaLibrary::addDiscoverer(std::unique_ptr<IDiscoverer> discoverer)
{
m_discoverers.emplace_back( std::move( discoverer ) );
}
void MediaLibrary::discover( const std::string &entryPoint )
{
for ( auto& d : m_discoverers )
......
......@@ -40,7 +40,6 @@ class MediaLibrary : public IMediaLibrary
virtual void addMetadataService( std::unique_ptr<IMetadataService> service );
virtual void parse( FilePtr file, IParserCb* cb );
virtual void addDiscoverer( std::unique_ptr<IDiscoverer> discoverer ) override;
virtual void discover( const std::string& entryPoint ) override;
// IDiscovererCb implementation
virtual FolderPtr onNewFolder( const fs::IDirectory* directory, FolderPtr parent ) override;
......
......@@ -28,12 +28,7 @@ void Tests::TearDown()
void Tests::Reload(std::shared_ptr<factory::IFileSystem> fs /* = nullptr */ )
{
ml.reset( MediaLibraryFactory::create() );
if ( fs != nullptr )
{
std::unique_ptr<IDiscoverer> discoverer( new FsDiscoverer( fs, ml.get() ) );
ml->addDiscoverer( std::move( discoverer ) );
}
else
if ( fs == nullptr )
{
fs = std::shared_ptr<factory::IFileSystem>( new mock::NoopFsFactory );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment