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

MediaLibrary: Don't silently fail when the medialibrary isn't started

Delegate the discovererWorker checks to the test implementation, which
is the only one allowed not to have a discoverer set
fix #78

(cherry picked from commit 77ddd240)
Signed-off-by: default avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent c4e36731
......@@ -1283,14 +1283,14 @@ void MediaLibrary::migrateModel14to15()
void MediaLibrary::reload()
{
if ( m_discovererWorker != nullptr )
m_discovererWorker->reload();
assert( m_discovererWorker != nullptr );
m_discovererWorker->reload();
}
void MediaLibrary::reload( const std::string& entryPoint )
{
if ( m_discovererWorker != nullptr )
m_discovererWorker->reload( entryPoint );
assert( m_discovererWorker != nullptr );
m_discovererWorker->reload( entryPoint );
}
bool MediaLibrary::forceParserRetry()
......@@ -1407,8 +1407,8 @@ std::shared_ptr<fs::IFileSystemFactory> MediaLibrary::fsFactoryForMrl( const std
void MediaLibrary::discover( const std::string& entryPoint )
{
if ( m_discovererWorker != nullptr )
m_discovererWorker->discover( entryPoint );
assert( m_discovererWorker != nullptr );
m_discovererWorker->discover( entryPoint );
}
void MediaLibrary::addNetworkFileSystemFactory( std::shared_ptr<fs::IFileSystemFactory> fsFactory )
......@@ -1492,20 +1492,20 @@ FolderPtr MediaLibrary::folder( const std::string& mrl ) const
void MediaLibrary::removeEntryPoint( const std::string& entryPoint )
{
if ( m_discovererWorker != nullptr )
m_discovererWorker->remove( entryPoint );
assert( m_discovererWorker != nullptr );
m_discovererWorker->remove( entryPoint );
}
void MediaLibrary::banFolder( const std::string& entryPoint )
{
if ( m_discovererWorker != nullptr )
m_discovererWorker->ban( entryPoint );
assert( m_discovererWorker != nullptr );
m_discovererWorker->ban( entryPoint );
}
void MediaLibrary::unbanFolder( const std::string& entryPoint )
{
if ( m_discovererWorker != nullptr )
m_discovererWorker->unban( entryPoint );
assert( m_discovererWorker != nullptr );
m_discovererWorker->unban( entryPoint );
}
const std::string& MediaLibrary::thumbnailPath() const
......
......@@ -44,6 +44,42 @@ MediaLibraryTester::MediaLibraryTester()
{
}
void MediaLibraryTester::removeEntryPoint( const std::string& entryPoint )
{
if ( m_discovererWorker != nullptr )
MediaLibrary::removeEntryPoint( entryPoint );
}
void MediaLibraryTester::reload()
{
if ( m_discovererWorker != nullptr )
MediaLibrary::reload();
}
void MediaLibraryTester::reload( const std::string& entryPoint )
{
if ( m_discovererWorker != nullptr )
MediaLibrary::reload( entryPoint );
}
void MediaLibraryTester::banFolder( const std::string& path )
{
if ( m_discovererWorker != nullptr )
MediaLibrary::banFolder( path );
}
void MediaLibraryTester::unbanFolder( const std::string& path )
{
if ( m_discovererWorker != nullptr )
MediaLibrary::unbanFolder( path );
}
void MediaLibraryTester::discover( const std::string& entryPoint )
{
if ( m_discovererWorker != nullptr )
MediaLibrary::discover( entryPoint );
}
std::shared_ptr<Media> MediaLibraryTester::media( int64_t id )
{
return std::static_pointer_cast<Media>( MediaLibrary::media( id ) );
......
......@@ -41,6 +41,12 @@ public:
virtual bool startParser() override { return true; }
virtual void startDiscoverer() override {}
virtual void startDeletionNotifier() override {}
virtual void removeEntryPoint( const std::string& entryPoint ) override;
virtual void reload() override;
virtual void reload( const std::string& entryPoint ) override;
virtual void banFolder( const std::string& path ) override;
virtual void unbanFolder( const std::string& path ) override;
virtual void discover( const std::string& entryPoint ) override;
std::vector<MediaPtr> files();
// Use the filename getter
using MediaLibrary::media;
......
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