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
virtual ~IFileSystem() = default;
///
/// \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
///
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 )
if ( fsFactory == nullptr )
return false;
auto folderFs = fsFactory->createDirectory( mrl );
if ( folderFs == nullptr )
return false;
assert( folderFs != nullptr );
auto deviceFs = folderFs->device();
auto device = Device::fromUuid( ml, deviceFs->uuid() );
if ( device == nullptr )
......@@ -169,8 +168,7 @@ std::shared_ptr<Folder> Folder::fromMrl( MediaLibraryPtr ml, const std::string&
if ( fsFactory == nullptr )
return nullptr;
auto folderFs = fsFactory->createDirectory( mrl );
if ( folderFs == nullptr )
return nullptr;
assert( folderFs != nullptr );
auto deviceFs = folderFs->device();
if ( deviceFs == nullptr )
{
......
......@@ -106,12 +106,6 @@ bool FsDiscoverer::discover( const std::string &entryPoint )
void FsDiscoverer::reloadFolder( Folder& f )
{
auto folder = m_fsFactory->createDirectory( f.mrl() );
if ( folder == nullptr )
{
LOG_INFO( "Removing folder ", f.mrl() );
m_ml->deleteFolder( f );
return;
}
try
{
checkFolder( *folder, f, false );
......
......@@ -61,16 +61,7 @@ FileSystemFactory::FileSystemFactory( DeviceListerPtr lister )
std::shared_ptr<fs::IDirectory> FileSystemFactory::createDirectory( const std::string& mrl )
{
try
{
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;
}
return std::make_shared<fs::Directory>( mrl, *this );
}
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