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

MetadataParser: Refresh the thumbnail when refreshing a media

Sort of cherry-picked from f379a95a
parent f3156c59
......@@ -421,6 +421,19 @@ bool Media::setThumbnail( const std::string& thumbnailMrl, Thumbnail::Origin ori
return true;
}
void Media::removeThumbnail()
{
if ( m_thumbnailId == 0 )
return;
static const std::string req = "UPDATE " + Media::Table::Name + " SET "
"thumbnail_id = ? WHERE id_media = ?";
if ( sqlite::Tools::executeUpdate( m_ml->getConn(), req, nullptr, m_id ) == false )
return;
Thumbnail::destroy( m_ml, m_thumbnailId );
m_thumbnailId = 0;
m_thumbnail = nullptr;
}
bool Media::setThumbnail( const std::string& thumbnailMrl )
{
return setThumbnail( thumbnailMrl, Thumbnail::Origin::UserProvided, false );
......
......@@ -118,6 +118,7 @@ class Media : public IMedia, public DatabaseHelpers<Media>
virtual bool setThumbnail( const std::string &thumbnail ) override;
bool setThumbnail( const std::string& thumbnail, Thumbnail::Origin origin,
bool isGenerated);
void removeThumbnail();
virtual unsigned int insertionDate() const override;
virtual unsigned int releaseDate() const override;
uint32_t nbPlaylists() const;
......
......@@ -607,6 +607,8 @@ std::tuple<bool, bool> MetadataAnalyzer::refreshMedia( IItem& item ) const
if ( albumArtist && albumArtist->id() != albumTrack->artistId() )
albumArtist->updateNbTrack( -1 );
if ( media->isThumbnailGenerated() == true )
media->removeThumbnail();
album->removeTrack( *media, *albumTrack );
AlbumTrack::destroy( m_ml, albumTrack->id() );
Artist::dropMediaArtistRelation( m_ml, media->id() );
......
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