Commit b0e657bb 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

(cherry picked from commit 5a840647

)
Signed-off-by: Hugo Beauzée-Luyssen's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent e422476d
...@@ -64,12 +64,12 @@ Folder::Folder( MediaLibraryPtr ml, sqlite::Row& row ) ...@@ -64,12 +64,12 @@ Folder::Folder( MediaLibraryPtr ml, sqlite::Row& row )
assert( row.hasRemainingColumns() == false ); 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 ) int64_t parent, int64_t deviceId, bool isRemovable )
: m_ml( ml ) : m_ml( ml )
, m_id( 0 ) , m_id( 0 )
, m_path( path ) , m_path( path )
, m_name( utils::url::decode( utils::file::directoryName( path ) ) ) , m_name( std::move( name ) )
, m_parent( parent ) , m_parent( parent )
, m_isBanned( false ) , m_isBanned( false )
, m_deviceId( deviceId ) , m_deviceId( deviceId )
...@@ -400,12 +400,13 @@ std::shared_ptr<Folder> Folder::create( MediaLibraryPtr ml, const std::string& m ...@@ -400,12 +400,13 @@ std::shared_ptr<Folder> Folder::create( MediaLibraryPtr ml, const std::string& m
fs::IDevice& deviceFs ) fs::IDevice& deviceFs )
{ {
std::string path; std::string path;
std::string name = utils::url::decode( utils::file::directoryName( mrl ) );
if ( device.isRemovable() == true ) if ( device.isRemovable() == true )
path = deviceFs.relativeMrl( mrl ); path = deviceFs.relativeMrl( mrl );
else else
path = mrl; path = mrl;
auto self = std::make_shared<Folder>( ml, path, parentId, device.id(), auto self = std::make_shared<Folder>( ml, path, std::move( name ), parentId,
deviceFs.isRemovable() ); device.id(), deviceFs.isRemovable() );
static const std::string req = "INSERT INTO " + Folder::Table::Name + static const std::string req = "INSERT INTO " + Folder::Table::Name +
"(path, name, parent_id, device_id, is_removable) VALUES(?, ?, ?, ?, ?)"; "(path, name, parent_id, device_id, is_removable) VALUES(?, ?, ?, ?, ?)";
if ( insert( ml, self, req, path, self->m_name, sqlite::ForeignKey( parentId ), if ( insert( ml, self, req, path, self->m_name, sqlite::ForeignKey( parentId ),
......
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
}; };
Folder( MediaLibraryPtr ml, sqlite::Row& row ); 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 ); int64_t deviceId , bool isRemovable );
static void createTable( sqlite::Connection* connection ); 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