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

factory: IFileSytem: Clarify that createDirectory can't fail

parent bbeb6bff
...@@ -43,6 +43,9 @@ namespace factory ...@@ -43,6 +43,9 @@ namespace factory
virtual ~IFileSystem() = default; virtual ~IFileSystem() = default;
/// ///
/// \brief createDirectory creates a representation of a directory /// \brief createDirectory creates a representation of a directory
/// \note This method can't fail. The representation of a directory will be created
/// but subsequent calls to IDirectory methods may fail if the directory
/// doesn't exist, or any other I/O issue occurs
/// \param path An absolute path to a directory /// \param path An absolute path to a directory
/// ///
virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& path ) = 0; virtual std::shared_ptr<fs::IDirectory> createDirectory( const std::string& path ) = 0;
......
...@@ -135,8 +135,7 @@ bool Folder::blacklist( MediaLibraryPtr ml, const std::string& mrl ) ...@@ -135,8 +135,7 @@ bool Folder::blacklist( MediaLibraryPtr ml, const std::string& mrl )
if ( fsFactory == nullptr ) if ( fsFactory == nullptr )
return false; return false;
auto folderFs = fsFactory->createDirectory( mrl ); auto folderFs = fsFactory->createDirectory( mrl );
if ( folderFs == nullptr ) assert( folderFs != nullptr );
return false;
auto deviceFs = folderFs->device(); auto deviceFs = folderFs->device();
auto device = Device::fromUuid( ml, deviceFs->uuid() ); auto device = Device::fromUuid( ml, deviceFs->uuid() );
if ( device == nullptr ) if ( device == nullptr )
...@@ -169,8 +168,7 @@ std::shared_ptr<Folder> Folder::fromMrl( MediaLibraryPtr ml, const std::string& ...@@ -169,8 +168,7 @@ std::shared_ptr<Folder> Folder::fromMrl( MediaLibraryPtr ml, const std::string&
if ( fsFactory == nullptr ) if ( fsFactory == nullptr )
return nullptr; return nullptr;
auto folderFs = fsFactory->createDirectory( mrl ); auto folderFs = fsFactory->createDirectory( mrl );
if ( folderFs == nullptr ) assert( folderFs != nullptr );
return nullptr;
auto deviceFs = folderFs->device(); auto deviceFs = folderFs->device();
if ( deviceFs == nullptr ) if ( deviceFs == nullptr )
{ {
......
...@@ -106,12 +106,6 @@ bool FsDiscoverer::discover( const std::string &entryPoint ) ...@@ -106,12 +106,6 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
void FsDiscoverer::reloadFolder( Folder& f ) void FsDiscoverer::reloadFolder( Folder& f )
{ {
auto folder = m_fsFactory->createDirectory( f.mrl() ); auto folder = m_fsFactory->createDirectory( f.mrl() );
if ( folder == nullptr )
{
LOG_INFO( "Removing folder ", f.mrl() );
m_ml->deleteFolder( f );
return;
}
try try
{ {
checkFolder( *folder, f, false ); checkFolder( *folder, f, false );
......
...@@ -61,16 +61,7 @@ FileSystemFactory::FileSystemFactory( DeviceListerPtr lister ) ...@@ -61,16 +61,7 @@ FileSystemFactory::FileSystemFactory( DeviceListerPtr lister )
std::shared_ptr<fs::IDirectory> FileSystemFactory::createDirectory( const std::string& mrl ) std::shared_ptr<fs::IDirectory> FileSystemFactory::createDirectory( const std::string& mrl )
{ {
try return std::make_shared<fs::Directory>( mrl, *this );
{
auto dir = std::make_shared<fs::Directory>( mrl, *this );
return dir;
}
catch(const std::system_error& ex)
{
LOG_ERROR( "Failed to create fs::IDirectory for ", mrl, ": ", ex.what());
return nullptr;
}
} }
std::shared_ptr<fs::IDevice> FileSystemFactory::createDevice( const std::string& uuid ) std::shared_ptr<fs::IDevice> FileSystemFactory::createDevice( const std::string& uuid )
......
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