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

MediaLibrary: Allow network fs factories to be added on the fly

parent 936c972e
......@@ -754,13 +754,10 @@ public:
* @brief addNetworkFileSystemFactory Provides a network filesystem factory implementation
* @return true if the factory is accepted & inserted
*
* This must be called between initialize() and start().
* A network file system factory must be inserted before enabling network
* file systems discovery.
* This must be called after initialize()
* Only a single IFileSystemFactory instance per scheme is allowed.
* If a factory is passed to this method and the scheme is already handled
* by another factory, false will be returned.
*
*/
virtual bool addNetworkFileSystemFactory( std::shared_ptr<fs::IFileSystemFactory> fsFactory ) = 0;
......
......@@ -1914,6 +1914,8 @@ void MediaLibrary::discover( const std::string& entryPoint )
bool MediaLibrary::addNetworkFileSystemFactory( std::shared_ptr<fs::IFileSystemFactory> fsFactory )
{
std::lock_guard<compat::Mutex> lock( m_mutex );
auto it = std::find_if( cbegin( m_externalNetworkFsFactories ),
cend( m_externalNetworkFsFactories ),
[&fsFactory]( const std::shared_ptr<fs::IFileSystemFactory>& fsf ) {
......@@ -1921,6 +1923,8 @@ bool MediaLibrary::addNetworkFileSystemFactory( std::shared_ptr<fs::IFileSystemF
});
if ( it != cend( m_externalNetworkFsFactories ) )
return false;
if ( m_networkDiscoveryEnabled == true )
m_fsFactories.push_back( fsFactory );
m_externalNetworkFsFactories.emplace_back( std::move( fsFactory ) );
return true;
}
......
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