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

File: Allow MRL to be edited

parent 71c7984d
......@@ -108,6 +108,17 @@ const std::string& File::mrl() const
return m_fullPath;
}
void File::setMrl( const std::string& mrl )
{
if ( m_mrl == mrl )
return;
const static std::string req = "UPDATE " + policy::FileTable::Name + " SET "
"mrl = ? WHERE id_file = ?";
if ( sqlite::Tools::executeUpdate( m_ml->getConn(), req, mrl, m_id ) == false )
return;
m_mrl = mrl;
}
IFile::Type File::type() const
{
return m_type;
......
......@@ -54,6 +54,7 @@ public:
File( MediaLibraryPtr ml, int64_t mediaId, int64_t playlistId, Type type, const std::string& mrl );
virtual int64_t id() const override;
virtual const std::string& mrl() const override;
void setMrl( const std::string& mrl );
virtual Type type() const override;
virtual unsigned int lastModificationDate() const override;
virtual unsigned int size() const override;
......
......@@ -75,3 +75,18 @@ TEST_F( Files, Media )
f = std::static_pointer_cast<File>( files[0] );
ASSERT_EQ( m->id(), f->media()->id() );
}
TEST_F( Files, SetMrl )
{
const std::string newMrl = "/sea/otters/rules.mkv";
f->setMrl( newMrl );
ASSERT_EQ( newMrl, f->mrl() );
Reload();
auto files = m->files();
ASSERT_EQ( 1u, files.size() );
f = std::static_pointer_cast<File>( files[0] );
ASSERT_EQ( f->mrl(), newMrl );
}
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