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

MediaLibrary: Only create the device when it is unknown

parent d1fbdb57
Pipeline #5150 failed with stages
in 15 minutes and 46 seconds
......@@ -1666,8 +1666,21 @@ bool MediaLibrary::DeviceListerCb::onDeviceMounted( const std::string& uuid,
else
{
m_ml->refreshDevices( *fsFactory );
if ( Device::create( m_ml, uuid, "file://", true ) == nullptr )
return false;
// Don't try to insert the device if we already know it
if ( currentDevice == nullptr )
{
try
{
if ( Device::create( m_ml, uuid, "file://", true ) == nullptr )
return false;
}
// And be conservative and assume another thread might have
// inserted the device between our previous check and now
catch ( const sqlite::errors::ConstraintViolation& )
{
return false;
}
}
}
break;
}
......
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