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

MediaLibrary: Allow file deletion

parent d3ea2310
......@@ -18,6 +18,8 @@ class IMediaLibrary
virtual bool initialize( const std::string& dbPath ) = 0;
virtual FilePtr addFile( const std::string& path ) = 0;
virtual FilePtr file( const std::string& path ) = 0;
virtual bool deleteFile( const std::string& mrl ) = 0;
virtual bool deleteFile( FilePtr file ) = 0;
virtual LabelPtr createLabel( const std::string& label ) = 0;
virtual bool deleteLabel( const std::string& label ) = 0;
virtual bool deleteLabel( LabelPtr label ) = 0;
......
......@@ -48,6 +48,16 @@ FilePtr MediaLibrary::addFile( const std::string& path )
return f;
}
bool MediaLibrary::deleteFile( const std::string& mrl )
{
return File::destroy( m_dbConnection, mrl );
}
bool MediaLibrary::deleteFile( FilePtr file )
{
return File::destroy( m_dbConnection, std::static_pointer_cast<File>( file ) );
}
LabelPtr MediaLibrary::createLabel( const std::string& label )
{
auto l = Label::create( label );
......
......@@ -13,6 +13,8 @@ class MediaLibrary : public IMediaLibrary
virtual bool files( std::vector<FilePtr>& res );
virtual FilePtr file( const std::string& path );
virtual FilePtr addFile( const std::string& path );
virtual bool deleteFile( const std::string& mrl );
virtual bool deleteFile( FilePtr file );
virtual LabelPtr createLabel( const std::string& label );
virtual bool deleteLabel(const std::string& text );
virtual bool deleteLabel( LabelPtr label );
......
......@@ -56,6 +56,18 @@ TEST_F( MLTest, FetchFile )
ASSERT_EQ( f, f2 );
}
TEST_F( MLTest, DeleteFile )
{
auto f = ml->addFile( "/dev/loutre" );
auto f2 = ml->file( "/dev/loutre" );
ASSERT_EQ( f, f2 );
ml->deleteFile( f );
f2 = ml->file( "/dev/loutre" );
ASSERT_EQ( f2, nullptr );
}
TEST_F( MLTest, AddLabel )
{
auto f = ml->addFile( "/dev/null" );
......
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