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

Task: Simplify & fix empty mrl tasks handling

The mrl wasn't assigned back to the corresponding variable, and was used
immediatly after.
This code leverages the "new" DeviceRemovedException which didn't exist
when this code was introduced. This also fixes an unlikely TOCTOU race

(cherry picked from commit 55792999)
Signed-off-by: default avatarHugo Beauzée-Luyssen <>
parent db3bcbea
......@@ -355,22 +355,17 @@ bool Task::restoreLinkedEntities()
assert( !"Can't process a file without a file nor an mrl" );
return false;
auto folder = Folder::fetch( m_ml, file->folderId() );
if ( folder == nullptr )
assert( !"Can't file the folder associated with a file" );
// If the folder can't be found in db while the file can, it looks
// a lot like a sporadic failure, since file are deleted through
// triggers when its parent folder gets deleted. Just postpone this.
return false;
mrl = file->mrl();
if ( folder->isPresent() == false )
catch ( const fs::DeviceRemovedException& )
LOG_WARN( "Postponing rescan of removable file ", file->rawMrl(),
" until the device containing it is present again" );
return false;
setMrl( file->mrl() );
setMrl( mrl );
auto fsFactory = m_ml->fsFactoryForMrl( mrl );
if ( fsFactory == nullptr )
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