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

IFileSytemFactory: Don't consider the absence of device an error

parent e4e3ed67
......@@ -61,7 +61,7 @@ namespace factory
///
/// \brief refresh Will cause any FS cache to be refreshed.
///
virtual bool refreshDevices() = 0;
virtual void refreshDevices() = 0;
///
/// \brief isPathSupported Checks for support of a path by this FS facotry
/// \param path The path to probe for support
......
......@@ -786,8 +786,7 @@ void MediaLibrary::refreshDevices( factory::IFileSystem& fsFactory )
// Don't refuse to process devices when none seem to be present, it might be a valid case
// if the user only discovered removable storages, and we would still need to mark those
// as "not present"
if ( fsFactory.refreshDevices() == false )
LOG_WARN( "No device detected." );
fsFactory.refreshDevices();
auto devices = Device::fetchAll( this );
for ( auto& d : devices )
{
......
......@@ -101,7 +101,7 @@ std::shared_ptr<fs::IDevice> FileSystemFactory::createDeviceFromMrl( const std::
return res;
}
bool FileSystemFactory::refreshDevices()
void FileSystemFactory::refreshDevices()
{
{
std::lock_guard<compat::Mutex> lock( m_mutex );
......@@ -111,11 +111,12 @@ bool FileSystemFactory::refreshDevices()
if ( m_deviceCache.isCached() == false )
m_deviceCache = DeviceCacheMap{};
m_deviceCache.get().clear();
LOG_INFO( "Refreshing devices from IDeviceLister" );
auto devices = m_deviceLister->devices();
if ( devices.empty() == true )
{
LOG_ERROR( "Cannot continue with no devices" );
return false;
LOG_WARN( "No device detected." );
return;
}
for ( const auto& d : devices )
{
......@@ -125,7 +126,7 @@ bool FileSystemFactory::refreshDevices()
LOG_INFO( "Caching device ", uuid, " mounted on ", mountpoint, ". Removable: ", removable ? "true" : "false" );
m_deviceCache.get().emplace( uuid, std::make_shared<fs::Device>( uuid, mountpoint, removable ) );
}
return true;
return;
}
bool FileSystemFactory::isMrlSupported( const std::string& path ) const
......
......@@ -45,7 +45,7 @@ namespace factory
virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& mrl ) override;
virtual std::shared_ptr<fs::IDevice> createDevice( const std::string& uuid ) override;
virtual std::shared_ptr<fs::IDevice> createDeviceFromMrl( const std::string& mrl ) override;
virtual bool refreshDevices() override;
virtual void refreshDevices() override;
virtual bool isMrlSupported( const std::string& path ) const override;
virtual bool isNetworkFileSystem() const override;
......
......@@ -80,9 +80,8 @@ std::shared_ptr<fs::IDevice> NetworkFileSystemFactory::createDeviceFromMrl( cons
return it->device;
}
bool NetworkFileSystemFactory::refreshDevices()
void NetworkFileSystemFactory::refreshDevices()
{
return true;
}
bool NetworkFileSystemFactory::isMrlSupported( const std::string& path ) const
......
......@@ -46,7 +46,7 @@ public:
virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& path ) override;
virtual std::shared_ptr<fs::IDevice> createDevice( const std::string& uuid ) override;
virtual std::shared_ptr<fs::IDevice> createDeviceFromMrl( const std::string& path ) override;
virtual bool refreshDevices() override;
virtual void refreshDevices() override;
virtual bool isMrlSupported( const std::string& path ) const override;
virtual bool isNetworkFileSystem() const override;
......
......@@ -178,9 +178,8 @@ struct FileSystemFactory : public factory::IFileSystem
return *it;
}
virtual bool refreshDevices() override
virtual void refreshDevices() override
{
return true;
}
std::shared_ptr<Device> device( const std::string& mrl )
......@@ -355,9 +354,8 @@ public:
return std::make_shared<NoopDevice>();
}
virtual bool refreshDevices() override
virtual void refreshDevices() override
{
return false;
}
virtual bool isMrlSupported( const std::string& mrl ) const override
......
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