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

FsDiscoverer: Avoid a potential corner case crash

parent 22f3be76
......@@ -282,7 +282,16 @@ void FsDiscoverer::checkFiles( fs::IDirectory& parentFolderFs, Folder& parentFol
for ( auto file : files )
{
LOG_INFO( "File ", file->mrl(), " not found on filesystem, deleting it" );
file->media()->removeFile( *file );
auto media = file->media();
if ( media != nullptr && media->isDeleted() == false )
media->removeFile( *file );
else if ( file->isDeleted() == false )
{
// This is unexpected, as the file should have been deleted when the media was
// removed.
LOG_WARN( "Deleting a file without an associated media." );
file->destroy();
}
}
for ( auto& f : filesToRemove )
f->media()->removeFile( *f );
......
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