Commit 8e9656c4 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Media: create: Expect a reference to IFile, since it can't be nullptr

parent a7dbfd85
......@@ -83,9 +83,9 @@ Media::Media( const std::string& title, Type type )
{
}
std::shared_ptr<Media> Media::create( DBConnection dbConnection, Type type, const fs::IFile* file )
std::shared_ptr<Media> Media::create( DBConnection dbConnection, Type type, const fs::IFile& file )
{
auto self = std::make_shared<Media>( file->name(), type );
auto self = std::make_shared<Media>( file.name(), type );
static const std::string req = "INSERT INTO " + policy::MediaTable::Name +
"(type, insertion_date, title) VALUES(?, ?, ?)";
......
......@@ -59,7 +59,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
Media( DBConnection dbConnection , sqlite::Row& row );
Media( const std::string &title, Type type);
static std::shared_ptr<Media> create( DBConnection dbConnection, Type type, const fs::IFile* file );
static std::shared_ptr<Media> create( DBConnection dbConnection, Type type, const fs::IFile& file );
static bool createTable( DBConnection connection );
static bool createTriggers( DBConnection connection );
......
......@@ -234,7 +234,7 @@ std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder& p
return nullptr;
LOG_INFO( "Adding ", path );
auto mptr = Media::create( m_dbConnection.get(), type, fileFs.get() );
auto mptr = Media::create( m_dbConnection.get(), type, *fileFs );
if ( mptr == nullptr )
{
LOG_ERROR( "Failed to add media ", fileFs->fullPath(), " to the media library" );
......
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