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

MediaLibrary: Only check relevant devices presence

parent 319de5ab
......@@ -145,4 +145,11 @@ void Device::removeOldDevices( MediaLibraryPtr ml, std::chrono::seconds maxLifeT
sqlite::Tools::executeDelete( ml->getConn(), req, deadline.count() );
}
std::vector<std::shared_ptr<Device>> Device::fetchByScheme( MediaLibraryPtr ml,
const std::string& scheme )
{
static const std::string req = "SELECT * FROM " + Table::Name + " WHERE scheme = ?";
return fetchAll<Device>( ml, req, scheme );
}
}
......@@ -62,6 +62,7 @@ public:
static void createTable( sqlite::Connection* connection );
static std::shared_ptr<Device> fromUuid( MediaLibraryPtr ml, const std::string& uuid );
static void removeOldDevices( MediaLibraryPtr ml, std::chrono::seconds maxLifeTime );
static std::vector<std::shared_ptr<Device>> fetchByScheme( MediaLibraryPtr ml, const std::string& scheme );
private:
MediaLibraryPtr m_ml;
......
......@@ -1431,7 +1431,7 @@ void MediaLibrary::refreshDevices( fs::IFileSystemFactory& fsFactory )
// if the user only discovered removable storages, and we would still need to mark those
// as "not present"
fsFactory.refreshDevices();
auto devices = Device::fetchAll( this );
auto devices = Device::fetchByScheme( this, fsFactory.scheme() );
for ( auto& d : devices )
{
auto deviceFs = fsFactory.createDevice( d->uuid() );
......
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