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

Don't expose deletion methods

This might need to be reverted when properly addressing files deletion
(while monitoring filesystem or when reloading)
However, as of now, I'm not confident this respect the object ownership
graph anyway
parent e80b62e3
......@@ -144,11 +144,6 @@ bool Album::addArtist( std::shared_ptr<Artist> artist )
return sqlite::Tools::executeRequest( m_dbConnection, req, m_id, artist->id() );
}
bool Album::destroy()
{
return _Cache::destroy( m_dbConnection, this );
}
bool Album::createTable(DBConnection dbConnection )
{
static const std::string req = "CREATE TABLE IF NOT EXISTS " +
......
......@@ -69,8 +69,6 @@ class Album : public IAlbum, public Cache<Album, IAlbum, policy::AlbumTable>
virtual std::vector<ArtistPtr> artists() const override;
bool addArtist( std::shared_ptr<Artist> artist );
bool destroy();
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<Album> create(DBConnection dbConnection, const std::string& title );
......
......@@ -117,16 +117,6 @@ bool Movie::setImdbId( const std::string& imdbId )
return true;
}
bool Movie::destroy()
{
auto fs = files();
for ( auto& f : fs )
{
Media::discard( std::static_pointer_cast<Media>( f ) );
}
return _Cache::destroy( m_dbConnection, this );
}
std::vector<MediaPtr> Movie::files()
{
static const std::string req = "SELECT * FROM " + policy::MediaTable::Name
......
......@@ -57,8 +57,6 @@ class Movie : public IMovie, public Cache<Movie, IMovie, policy::MovieTable>
bool setImdbId(const std::string& imdbId);
virtual std::vector<MediaPtr> files() override;
bool destroy();
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<Movie> create( DBConnection dbConnection, const std::string& title );
......
......@@ -135,18 +135,6 @@ std::vector<ShowEpisodePtr> Show::episodes()
return ShowEpisode::fetchAll( m_dbConnection, req, m_id );
}
bool Show::destroy()
{
auto eps = episodes();
//FIXME: This is suboptimal. Each episode::destroy() will fire a SQL request of its own
for ( auto& it : eps )
{
auto e = std::static_pointer_cast<ShowEpisode>( it );
e->destroy();
}
return _Cache::destroy( m_dbConnection, this );
}
bool Show::createTable(DBConnection dbConnection)
{
const std::string req = "CREATE TABLE IF NOT EXISTS " + policy::ShowTable::Name + "("
......
......@@ -62,7 +62,6 @@ class Show : public IShow, public Cache<Show, IShow, policy::ShowTable>
std::shared_ptr<ShowEpisode> addEpisode( const std::string& title, unsigned int episodeNumber );
virtual std::vector<ShowEpisodePtr> episodes() override;
bool destroy();
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<Show> create( DBConnection dbConnection, const std::string& name );
......
......@@ -148,14 +148,6 @@ std::vector<MediaPtr> ShowEpisode::files()
return Media::fetchAll( m_dbConnection, req, m_id );
}
bool ShowEpisode::destroy()
{
auto fs = files();
for ( auto& f : fs )
Media::discard( std::static_pointer_cast<Media>( f ) );
return _Cache::destroy( m_dbConnection, this );
}
bool ShowEpisode::createTable( DBConnection dbConnection )
{
const std::string req = "CREATE TABLE IF NOT EXISTS " + policy::ShowEpisodeTable::Name
......
......@@ -63,7 +63,6 @@ class ShowEpisode : public IShowEpisode, public Cache<ShowEpisode, IShowEpisode,
bool setTvdbId( const std::string& tvdbId );
virtual std::shared_ptr<IShow> show() override;
virtual std::vector<MediaPtr> files() override;
bool destroy();
static bool createTable( DBConnection dbConnection );
static std::shared_ptr<ShowEpisode> create( DBConnection dbConnection, const std::string& title, unsigned int episodeNumber, unsigned int showId );
......
......@@ -90,20 +90,6 @@ TEST_F( Albums, AssignTrack )
ASSERT_EQ( t->title(), f->name() );
}
//TEST_F( Albums, DeleteTrack )
//{
// auto f = ml->addFile( "file.mp3", nullptr );
// auto a = ml->createAlbum( "album" );
// auto t = a->addTrack( f, 1 );
// f->setAlbumTrack( t );
// bool res = t->destroy();
// ASSERT_TRUE( res );
// auto f2 = ml->file( "file.mp3" );
// ASSERT_EQ( f2, nullptr );
//}
TEST_F( Albums, SetGenre )
{
auto a = ml->createAlbum( "album" );
......@@ -178,20 +164,6 @@ TEST_F( Albums, FetchAlbumFromTrack )
ASSERT_EQ( a->title(), "album" );
}
TEST_F( Albums, DestroyAlbum )
{
// auto a = ml->createAlbum( "album" );
// auto f = ml->addFile( "file.mp3", nullptr );
// auto t = a->addTrack( f, 1 );
// f->setAlbumTrack( t );
// bool res = a->destroy();
// ASSERT_TRUE( res );
// f = std::static_pointer_cast<Media>( ml->file( "file.mp3" ) );
// ASSERT_EQ( f, nullptr );
}
TEST_F( Albums, Artists )
{
auto album = ml->createAlbum( "album" );
......
......@@ -119,20 +119,3 @@ TEST_F( Movies, AssignToFile )
ASSERT_NE( m2, nullptr );
ASSERT_EQ( m2->title(), "movie" );
}
TEST_F( Movies, DestroyMovie )
{
auto f = ml->addFile( "file.avi", nullptr );
auto m = ml->createMovie( "movie" );
f->setMovie( m );
m->destroy();
auto f2 = ml->file( "file.avi" );
ASSERT_EQ( f2, nullptr );
Reload();
f2 = ml->file( "file.avi" );
ASSERT_EQ( f2, nullptr );
}
......@@ -228,33 +228,3 @@ TEST_F( Shows, FileSetShowEpisode )
ASSERT_EQ( e2->name(), "episode 1" );
}
TEST_F( Shows, DeleteShowEpisode )
{
auto show = ml->createShow( "show" );
auto e = show->addEpisode( "episode 1", 1 );
auto f = ml->addFile( "file.avi", nullptr );
f->setShowEpisode( e );
e->destroy();
f = std::static_pointer_cast<Media>( ml->file( "file.avi" ) );
ASSERT_EQ( f, nullptr );
Reload();
auto f2 = ml->file( "file.avi" );
ASSERT_EQ( f2, nullptr );
}
TEST_F( Shows, DeleteShow )
{
auto show = ml->createShow( "show" );
auto e = show->addEpisode( "episode 1", 1 );
auto f = ml->addFile( "file.avi", nullptr );
f->setShowEpisode( e );
bool res = show->destroy();
ASSERT_TRUE( res );
auto f2 = ml->file( "file.avi" );
ASSERT_EQ( f2, nullptr );
}
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