Commit 174644d4 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Folder: Fix generation of root folder names

When a folde represent a mountpoint, we can't generate its name upon
insertion, as the mountpoint path is only known at runtime.
Fix #72

(cherry picked from commit 77f558f2)
Signed-off-by: 's avatarHugo Beauzée-Luyssen <hugo@beauzee.fr>
parent 8ae1bc27
Pipeline #5474 failed with stages
in 13 minutes
......@@ -436,6 +436,14 @@ const std::string& Folder::mrl() const
const std::string&Folder::name() const
{
if ( m_isRemovable == true && m_name.empty() == true )
{
// In case this is the root folder of an external device, we don't have
// any information before knowing the actual mountpoint, so we have to do
// this at runtime
auto fullPath = mrl();
m_name = utils::url::decode( utils::file::directoryName( fullPath ) );
}
return m_name;
}
......
......@@ -112,7 +112,7 @@ private:
// This contains the path relative to the device mountpoint (ie. excluding it)
// or the full path (including mrl scheme) for folders on non removable devices
std::string m_path;
std::string m_name;
mutable std::string m_name;
const int64_t m_parent;
const bool m_isBanned;
const int64_t m_deviceId;
......
......@@ -462,3 +462,14 @@ TEST_F( DeviceFs, OutdatedDevices )
ASSERT_NE( oldMediaCount, ml->files().size() );
}
TEST_F( DeviceFs, RemovableMountPointName )
{
ml->discover( mock::FileSystemFactory::Root );
bool discovered = cbMock->waitDiscovery();
ASSERT_TRUE( discovered );
auto f = ml->folder( RemovableDeviceMountpoint );
ASSERT_NE( nullptr, f );
ASSERT_NE( 0u, f->name().size() );
}
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