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

FsDiscoverer: Move fetching files from parent folder to the File class

parent 740e21f5
......@@ -345,5 +345,13 @@ std::shared_ptr<File> File::fromExternalMrl( MediaLibraryPtr ml, const std::stri
return file;
}
std::vector<std::shared_ptr<File>> File::fromParentFolder( MediaLibraryPtr ml,
int64_t parentFolderId )
{
static const std::string req = "SELECT * FROM " + File::Table::Name
+ " WHERE folder_id = ?";
return File::fetchAll<File>( ml, req, parentFolderId );
}
}
......@@ -103,6 +103,14 @@ public:
*/
static std::shared_ptr<File> fromExternalMrl( MediaLibraryPtr ml, const std::string& mrl );
/**
* @brief fromParentFolder Returns a vector of the known file in a given folder
* @param ml The medialibrary instance pointer
* @param parentFolderId The parent folder ID
*/
static std::vector<std::shared_ptr<File>> fromParentFolder( MediaLibraryPtr ml,
int64_t parentFolderId );
private:
MediaLibraryPtr m_ml;
......
......@@ -300,9 +300,8 @@ void FsDiscoverer::checkFiles( std::shared_ptr<fs::IDirectory> parentFolderFs,
std::shared_ptr<Folder> parentFolder ) const
{
LOG_INFO( "Checking file in ", parentFolderFs->mrl() );
static const std::string req = "SELECT * FROM " + File::Table::Name
+ " WHERE folder_id = ?";
auto files = File::fetchAll<File>( m_ml, req, parentFolder->id() );
auto files = File::fromParentFolder( m_ml, parentFolder->id() );
std::vector<std::shared_ptr<fs::IFile>> filesToAdd;
std::vector<std::pair<std::shared_ptr<File>, std::shared_ptr<fs::IFile>>> filesToRefresh;
for ( const auto& fileFs: parentFolderFs->files() )
......
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