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

MediaLibrary: Only create the device when it is unknown

(cherry picked from commit 0488ed41)
Signed-off-by: 's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 31ea152a
Pipeline #5151 failed with stages
in 17 minutes and 58 seconds
......@@ -1636,8 +1636,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