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

Folder: Don't store an empty name for removable folders

Fix #396
parent 4b999490
......@@ -65,12 +65,12 @@ Folder::Folder( MediaLibraryPtr ml, sqlite::Row& row )
assert( row.hasRemainingColumns() == false );
}
Folder::Folder(MediaLibraryPtr ml, const std::string& path,
Folder::Folder(MediaLibraryPtr ml, const std::string& path, std::string name,
int64_t parent, int64_t deviceId, bool isRemovable )
: m_ml( ml )
, m_id( 0 )
, m_path( path )
, m_name( utils::url::decode( utils::file::directoryName( path ) ) )
, m_name( std::move( name ) )
, m_parent( parent )
, m_isBanned( false )
, m_deviceId( deviceId )
......@@ -400,12 +400,13 @@ std::shared_ptr<Folder> Folder::create( MediaLibraryPtr ml, const std::string& m
fs::IDevice& deviceFs )
{
std::string path;
std::string name = utils::url::decode( utils::file::directoryName( mrl ) );
if ( device.isRemovable() == true )
path = deviceFs.relativeMrl( mrl );
else
path = mrl;
auto self = std::make_shared<Folder>( ml, path, parentId, device.id(),
deviceFs.isRemovable() );
auto self = std::make_shared<Folder>( ml, path, std::move( name ), parentId,
device.id(), deviceFs.isRemovable() );
static const std::string req = "INSERT INTO " + Folder::Table::Name +
"(path, name, parent_id, device_id, is_removable) VALUES(?, ?, ?, ?, ?)";
if ( insert( ml, self, req, path, self->m_name, sqlite::ForeignKey( parentId ),
......
......@@ -93,7 +93,7 @@ public:
};
Folder( MediaLibraryPtr ml, sqlite::Row& row );
Folder( MediaLibraryPtr ml, const std::string& path, int64_t parent,
Folder(MediaLibraryPtr ml, const std::string& path, std::string name, int64_t parent,
int64_t deviceId , bool isRemovable );
static void createTable( sqlite::Connection* connection );
......
Supports Markdown
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