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

IMediaLibrary: Drop the fsFactory parameter from initialize()

parent 712b7c5e
......@@ -30,7 +30,13 @@ class IMediaLibrary
/// \param dbPath Path to the database
/// \return true in case of success, false otherwise
///
virtual bool initialize( const std::string& dbPath, const std::string& snapshotPath, std::shared_ptr<factory::IFileSystem> fsFactory, IMetadataCb* metadataCb ) = 0;
virtual bool initialize( const std::string& dbPath, const std::string& snapshotPath, IMetadataCb* metadataCb ) = 0;
/**
* Replaces the default filesystem factory
* The default one will use standard opendir/readdir functions
* Calling this after initialize() is not a supported scenario.
*/
virtual void setFsFactory( std::shared_ptr<factory::IFileSystem> fsFactory ) = 0;
/// Adds a stand alone file
virtual FilePtr addFile( const std::string& path ) = 0;
virtual FilePtr file( const std::string& path ) = 0;
......
......@@ -63,11 +63,14 @@ MediaLibrary::~MediaLibrary()
AudioTrack::clear();
}
bool MediaLibrary::initialize( const std::string& dbPath, const std::string& snapshotPath, std::shared_ptr<factory::IFileSystem> fsFactory, IMetadataCb* metadataCb )
void MediaLibrary::setFsFactory(std::shared_ptr<factory::IFileSystem> fsFactory)
{
if ( fsFactory != nullptr )
m_fsFactory = fsFactory;
else
}
bool MediaLibrary::initialize( const std::string& dbPath, const std::string& snapshotPath, IMetadataCb* metadataCb )
{
if ( m_fsFactory == nullptr )
m_fsFactory.reset( new factory::FileSystemDefaultFactory );
m_snapshotPath = snapshotPath;
m_metadataCb = metadataCb;
......
......@@ -13,7 +13,8 @@ class MediaLibrary : public IMediaLibrary, public IDiscovererCb
public:
MediaLibrary();
~MediaLibrary();
virtual bool initialize( const std::string& dbPath, const std::string& snapshotPath, std::shared_ptr<factory::IFileSystem> fsFactory, IMetadataCb* metadataCb );
virtual bool initialize( const std::string& dbPath, const std::string& snapshotPath, IMetadataCb* metadataCb );
virtual void setFsFactory( std::shared_ptr<factory::IFileSystem> fsFactory ) override;
virtual std::vector<FilePtr> files();
virtual FilePtr file( const std::string& path );
......
......@@ -32,7 +32,8 @@ void Tests::Reload(std::shared_ptr<factory::IFileSystem> fs /*= nullptr*/, IMeta
{
fs = std::shared_ptr<factory::IFileSystem>( new mock::NoopFsFactory );
}
bool res = ml->initialize( "test.db", "/tmp", fs, metadataCb );
ml->setFsFactory( fs );
bool res = ml->initialize( "test.db", "/tmp", metadataCb );
ASSERT_TRUE( res );
}
......
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