Media: Fix update of cached metadata

parent 0c840665
......@@ -313,7 +313,7 @@ bool Media::setMetadata( IMedia::MetadataType type, const std::string& value )
return m.m_type == type;
});
if ( it != end( m_metadata.get() ) )
(*it).m_value = value;
(*it).set( value );
else
m_metadata.get().emplace_back( type, value );
}
......@@ -690,4 +690,10 @@ const std::string& Media::MediaMetadata::str() const
return m_value;
}
void Media::MediaMetadata::set( const std::string& value )
{
m_value = value;
m_isSet = true;
}
}
......@@ -68,6 +68,9 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
virtual const std::string& str() const override;
private:
void set( const std::string& value );
private:
MetadataType m_type;
std::string m_value;
bool m_isSet;
......
......@@ -132,6 +132,7 @@ TEST_F( Medias, Progress )
ASSERT_EQ( 0, f->metadata( Media::MetadataType::Progress ).integer() );
f->setMetadata( Media::MetadataType::Progress, 123 );
ASSERT_EQ( 123, f->metadata( Media::MetadataType::Progress ).integer() );
ASSERT_TRUE( f->metadata( Media::MetadataType::Progress ).isSet() );
Reload();
......@@ -145,6 +146,7 @@ TEST_F( Medias, Rating )
ASSERT_FALSE( f->metadata( Media::MetadataType::Rating ).isSet() );
f->setMetadata( Media::MetadataType::Rating, 12345 );
ASSERT_EQ( 12345, f->metadata( Media::MetadataType::Rating ).integer() );
ASSERT_TRUE( f->metadata( Media::MetadataType::Rating ).isSet() );
Reload();
......
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 sign in to comment