Skip to content
Snippets Groups Projects

Various network fs fixes

5 files
+ 22
16
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -48,6 +48,8 @@ NetworkFileSystemFactory::NetworkFileSystemFactory( MediaLibraryPtr ml,
: m_scheme( scheme )
, m_deviceLister( ml->deviceListerLocked( scheme ) )
{
m_isNetwork = strncasecmp( m_scheme.c_str(), "file://",
m_scheme.length() ) != 0;
}
std::shared_ptr<fs::IDirectory> NetworkFileSystemFactory::createDirectory( const std::string& mrl )
@@ -102,7 +104,7 @@ bool NetworkFileSystemFactory::isMrlSupported( const std::string& mrl ) const
bool NetworkFileSystemFactory::isNetworkFileSystem() const
{
return true;
return m_isNetwork;
}
const std::string& NetworkFileSystemFactory::scheme() const
@@ -125,7 +127,6 @@ bool NetworkFileSystemFactory::onDeviceMounted( const std::string& uuid,
const std::string& mountpoint,
bool removable )
{
assert( removable == true );
auto addMountpoint = true;
std::shared_ptr<fs::IDevice> device;
{
@@ -133,7 +134,8 @@ bool NetworkFileSystemFactory::onDeviceMounted( const std::string& uuid,
device = deviceByUuidLocked( uuid );
if ( device == nullptr )
{
device = std::make_shared<fs::NetworkDevice>( uuid, mountpoint, m_scheme );
device = std::make_shared<fs::NetworkDevice>( uuid, mountpoint,
m_scheme, removable );
m_devices.push_back( device );
addMountpoint = false;
}
@@ -176,14 +178,21 @@ std::shared_ptr<fs::IDevice> NetworkFileSystemFactory::deviceByUuidLocked( const
std::shared_ptr<fs::IDevice> NetworkFileSystemFactory::deviceByMrlLocked( const std::string& mrl )
{
auto it = std::find_if( begin( m_devices ), end( m_devices ),
[&mrl]( const std::shared_ptr<fs::IDevice>& d ) {
std::shared_ptr<fs::IDevice> res;
std::string mountpoint;
for ( const auto& d : m_devices )
{
auto match = d->matchesMountpoint( mrl );
return std::get<0>( match );
});
if ( it == end( m_devices ) )
return nullptr;
return *it;
if ( std::get<0>( match ) == false )
continue;
auto newMountpoint = std::get<1>( match );
if ( res == nullptr || newMountpoint.length() > mountpoint.length() )
{
res = d;
mountpoint = std::move( newMountpoint );
}
}
return res;
}
}
Loading