Commit 83350480 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

MediaLibrary: Provide the FsHolder instance to the DiscovererWorker

Which allows us to remove some of the forwarding calls in MediaLibrary
parent c31d9702
......@@ -1112,7 +1112,7 @@ void MediaLibrary::startDiscovererLocked()
if ( m_discovererWorker != nullptr )
return;
auto discoverer = std::make_unique<FsDiscoverer>( this, m_callback );
m_discovererWorker.reset( new DiscovererWorker( this,
m_discovererWorker.reset( new DiscovererWorker( this, &m_fsHolder,
std::move( discoverer ) ) );
}
......@@ -2613,11 +2613,6 @@ DiscovererWorker* MediaLibrary::getDiscovererWorker()
return m_discovererWorker.get();
}
void MediaLibrary::startFsFactoriesAndRefresh()
{
m_fsHolder.startFsFactoriesAndRefresh();
}
void MediaLibrary::refreshDevices( fs::IFileSystemFactory& fsFactory )
{
auto devices = Device::fetchByScheme( this, fsFactory.scheme() );
......
......@@ -343,7 +343,6 @@ private:
public:
void refreshDevice( Device& device, fs::IFileSystemFactory* fsFactory );
DiscovererWorker* getDiscovererWorker();
void startFsFactoriesAndRefresh();
protected:
virtual void addLocalFsFactory();
......
......@@ -43,7 +43,7 @@
namespace medialibrary
{
DiscovererWorker::DiscovererWorker( MediaLibrary* ml,
DiscovererWorker::DiscovererWorker(MediaLibrary* ml, FsHolder* fsHolder,
std::unique_ptr<FsDiscoverer> discoverer )
: m_currentTask( nullptr )
, m_run( true )
......@@ -51,7 +51,13 @@ DiscovererWorker::DiscovererWorker( MediaLibrary* ml,
, m_ml( ml )
, m_thread( &DiscovererWorker::run, this )
, m_discoveryNotified( false )
, m_fsHolder( fsHolder )
{
/*
* We can't use a reference as we need a default constructor to be valid for
* the unit tests constructor
*/
assert( fsHolder != nullptr );
}
DiscovererWorker::~DiscovererWorker()
......@@ -574,7 +580,7 @@ void DiscovererWorker::runReloadDevice( int64_t deviceId )
void DiscovererWorker::runReloadAllDevices()
{
m_ml->startFsFactoriesAndRefresh();
m_fsHolder->startFsFactoriesAndRefresh();
MediaLibrary::removeOldEntities( m_ml );
}
......
......@@ -37,6 +37,7 @@ namespace medialibrary
{
class MediaLibrary;
class FsHolder;
namespace parser
{
......@@ -77,7 +78,8 @@ protected:
DiscovererWorker() = default;
public:
DiscovererWorker( MediaLibrary* ml, std::unique_ptr<FsDiscoverer> discoverer );
DiscovererWorker( MediaLibrary* ml, FsHolder* fsHolder,
std::unique_ptr<FsDiscoverer> discoverer );
virtual ~DiscovererWorker();
void stop();
void pause();
......@@ -118,6 +120,7 @@ protected:
MediaLibrary* m_ml;
compat::Thread m_thread;
bool m_discoveryNotified;
FsHolder* m_fsHolder;
friend std::ostream& operator<<( std::ostream& s, DiscovererWorker::Task::Type& t );
};
......
Supports Markdown
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