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

MetadataParser: Move media refreshing in its own method

parent 9fe98342
......@@ -498,12 +498,35 @@ std::tuple<bool, bool> MetadataAnalyzer::refreshFile( IItem& item ) const
{
assert( item.media() == nullptr );
assert( item.file() != nullptr );
auto file = std::static_pointer_cast<File>( item.file() );
auto media = file->media();
auto file = std::static_pointer_cast<File>( item.file() );
file->updateFsInfo( item.fileFs()->lastModificationDate(), item.fileFs()->size() );
switch ( file->type() )
{
case IFile::Type::Main:
return refreshMedia( item );
case IFile::Type::Part:
case IFile::Type::Soundtrack:
case IFile::Type::Subtitles:
case IFile::Type::Playlist:
case IFile::Type::Disc:
case IFile::Type::Unknown:
break;
}
LOG_WARN( "Refreshing of file type ",
static_cast<std::underlying_type<IFile::Type>::type>( file->type() ),
" is unsupported" );
return { false, false };
}
std::tuple<bool, bool> MetadataAnalyzer::refreshMedia( IItem& item ) const
{
auto file = std::static_pointer_cast<File>( item.file() );
auto media = file->media();
assert( media != nullptr );
if ( media->duration() != item.duration() )
media->setDuration( item.duration() );
......
......@@ -56,6 +56,7 @@ protected:
std::tuple<Status, bool> createFileAndMedia( IItem& item ) const;
void createTracks( Media& m, const std::vector<IItem::Track>& tracks ) const;
std::tuple<bool, bool> refreshFile( IItem& item ) const;
std::tuple<bool, bool> refreshMedia( IItem& item ) const;
std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> findOrCreateArtist( IItem& item ) const;
std::shared_ptr<AlbumTrack> handleTrack( std::shared_ptr<Album> album, IItem& item,
std::shared_ptr<Artist> artist, Genre* genre ) const;
......
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