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

File: Create the file with a default filename

parent 0e93d967
......@@ -38,7 +38,7 @@ File::File( DBConnection dbConnection, sqlite3_stmt* stmt )
m_name = sqlite::Traits<std::string>::Load( stmt, 12 );
}
File::File( const fs::IFile* file, unsigned int folderId )
File::File( const fs::IFile* file, unsigned int folderId, const std::string& name )
: m_id( 0 )
, m_type( Type::UnknownType )
, m_duration( 0 )
......@@ -50,17 +50,19 @@ File::File( const fs::IFile* file, unsigned int folderId )
, m_folderId( folderId )
, m_lastModificationDate( file->lastModificationDate() )
, m_isParsed( false )
, m_name( name )
{
}
//FIXME: Pass the guessed type and default name
FilePtr File::create( DBConnection dbConnection, const fs::IFile* file, unsigned int folderId )
{
auto self = std::make_shared<File>( file, folderId );
auto self = std::make_shared<File>( file, folderId, file->name() );
static const std::string req = "INSERT INTO " + policy::FileTable::Name +
"(mrl, folder_id, last_modification_date) VALUES(?, ?, ?)";
"(mrl, folder_id, last_modification_date, name) VALUES(?, ?, ?, ?)";
if ( _Cache::insert( dbConnection, self, req, self->m_mrl, sqlite::ForeignKey( folderId ), self->m_lastModificationDate ) == false )
if ( _Cache::insert( dbConnection, self, req, self->m_mrl, sqlite::ForeignKey( folderId ),
self->m_lastModificationDate, self->m_name ) == false )
return nullptr;
self->m_dbConnection = dbConnection;
return self;
......
......@@ -40,7 +40,7 @@ class File : public IFile, public Cache<File, IFile, policy::FileTable, policy::
// shall be well-formed, and private constructor would prevent that.
// There might be a way with a user-defined allocator, but we'll see that later...
File(DBConnection dbConnection , sqlite3_stmt* stmt);
File(const fs::IFile* file , unsigned int folderId);
File(const fs::IFile* file , unsigned int folderId, const std::string &name);
static FilePtr create(DBConnection dbConnection, const fs::IFile* file , unsigned int folderId);
static bool createTable( DBConnection connection );
......
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