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

IAlbumTrack: Remove media() getter

parent d7ae87cc
......@@ -49,7 +49,6 @@ class IAlbumTrack
virtual unsigned int trackNumber() const = 0;
virtual AlbumPtr album() = 0;
virtual int64_t albumId() const = 0;
virtual MediaPtr media() = 0;
/**
* @return Which disc this tracks appears on (or 0 if unspecified)
*/
......
......@@ -143,7 +143,6 @@ std::shared_ptr<AlbumTrack> AlbumTrack::create( MediaLibraryPtr ml, int64_t albu
if ( insert( ml, self, req, media->id(), duration >= 0 ? duration : 0, sqlite::ForeignKey( artistId ),
sqlite::ForeignKey( genreId ), trackNb, albumId, discNumber ) == false )
return nullptr;
self->m_media = media;
return self;
}
......@@ -262,14 +261,4 @@ int64_t AlbumTrack::albumId() const
return m_albumId;
}
std::shared_ptr<IMedia> AlbumTrack::media()
{
auto lock = m_media.lock();
if ( m_media.isCached() == false )
{
m_media = Media::fetch( m_ml, m_mediaId );
}
return m_media.get().lock();
}
}
......@@ -68,7 +68,6 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
virtual unsigned int discNumber() const override;
virtual std::shared_ptr<IAlbum> album() override;
virtual int64_t albumId() const override;
virtual std::shared_ptr<IMedia> media() override;
static void createTable( sqlite::Connection* dbConnection );
static void createTriggers( sqlite::Connection* dbConnection );
......@@ -93,7 +92,6 @@ class AlbumTrack : public IAlbumTrack, public DatabaseHelpers<AlbumTrack, policy
mutable Cache<std::weak_ptr<Album>> m_album;
mutable Cache<std::shared_ptr<Artist>> m_artist;
mutable Cache<std::shared_ptr<Genre>> m_genre;
mutable Cache<std::weak_ptr<Media>> m_media;
friend struct policy::AlbumTrackTable;
};
......
......@@ -72,25 +72,6 @@ TEST_F( AlbumTracks, SetGenre )
ASSERT_EQ( t->genre()->id(), t2->albumTrack()->genre()->id() );
}
TEST_F( AlbumTracks, Media )
{
auto album = ml->createAlbum( "album" );
auto f = std::static_pointer_cast<Media>( ml->addMedia( "track1.mp3" ) );
auto track = album->addTrack( f, 1, 10, 0, nullptr );
f->save();
auto media = track->media();
ASSERT_NE( nullptr, media );
ASSERT_EQ( media->id(), f->id() );
Reload();
track = ml->albumTrack( track->id() );
media = track->media();
ASSERT_NE( nullptr, media );
ASSERT_EQ( media->id(), f->id() );
}
TEST_F( AlbumTracks, Album )
{
auto album = ml->createAlbum( "album" );
......
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