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

MediLibrary: deleteFolder: Pass a reference to the folder to delete

parent 17699ae8
......@@ -253,9 +253,9 @@ std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder& p
return mptr;
}
bool MediaLibrary::deleteFolder( const Folder* folder )
bool MediaLibrary::deleteFolder( const Folder& folder )
{
if ( Folder::destroy( m_dbConnection.get(), folder->id() ) == false )
if ( Folder::destroy( m_dbConnection.get(), folder.id() ) == false )
return false;
Media::clear();
return true;
......
......@@ -56,7 +56,7 @@ class MediaLibrary : public IMediaLibrary
virtual std::vector<MediaPtr> videoFiles() override;
std::shared_ptr<Media> addFile( const std::string& path, Folder& parentFolder, fs::IDirectory& parentFolderFs );
bool deleteFolder( const Folder* folder );
bool deleteFolder(const Folder& folder );
std::shared_ptr<Device> device( const std::string& uuid );
std::shared_ptr<Device> addDevice( const std::string& uuid, bool isRemovable );
......
......@@ -78,7 +78,7 @@ void FsDiscoverer::reload()
if ( folder == nullptr )
{
LOG_INFO( "Removing folder ", f->path() );
m_ml->deleteFolder( f.get() );
m_ml->deleteFolder( *f );
continue;
}
checkSubfolders( *folder, *f, blist );
......@@ -145,7 +145,7 @@ bool FsDiscoverer::checkSubfolders( fs::IDirectory& parentFolderFs, Folder& pare
for ( auto f : subFoldersInDB )
{
LOG_INFO( "Folder ", f->path(), " not found in FS, deleting it" );
m_ml->deleteFolder( f.get() );
m_ml->deleteFolder( *f );
}
LOG_INFO( "Done checking subfolders in ", parentFolderFs.path() );
return true;
......
......@@ -87,7 +87,7 @@ TEST_F( Folders, Delete )
auto files = ml->files();
ASSERT_EQ( files.size(), 3u );
ml->deleteFolder( f.get() );
ml->deleteFolder( *f );
f = ml->folder( folderPath );
ASSERT_EQ( nullptr, f );
......
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