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

FsDiscoverer: Pass newly discovered file type

refs #29
parent e67a95c3
......@@ -440,9 +440,10 @@ bool MediaLibrary::isExtensionSupported( const char* ext )
}
void MediaLibrary::onDiscoveredFile( std::shared_ptr<fs::IFile> fileFs,
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
std::pair<std::shared_ptr<Playlist>, unsigned int> parentPlaylist )
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
IFile::Type fileType,
std::pair<std::shared_ptr<Playlist>, unsigned int> parentPlaylist )
{
auto mrl = fileFs->mrl();
try
......@@ -462,8 +463,7 @@ void MediaLibrary::onDiscoveredFile( std::shared_ptr<fs::IFile> fileFs,
}
}
task = parser::Task::create( this, std::move( fileFs ), std::move( parentFolder ),
std::move( parentFolderFs ),
IFile::Type::Main,
std::move( parentFolderFs ), fileType,
std::move( parentPlaylist ) );
if ( task != nullptr && m_parser != nullptr )
m_parser->parse( task );
......
......@@ -85,6 +85,7 @@ public:
virtual void onDiscoveredFile( std::shared_ptr<fs::IFile> fileFs,
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
IFile::Type fileType,
std::pair<std::shared_ptr<Playlist>, unsigned int> parentPlaylist );
void onUpdatedFile( std::shared_ptr<File> file,
std::shared_ptr<fs::IFile> fileFs );
......
......@@ -352,7 +352,8 @@ void FsDiscoverer::checkFiles( std::shared_ptr<fs::IDirectory> parentFolderFs,
m_ml->onUpdatedFile( std::move( p.first ), std::move( p.second ) );
// Insert all files at once to avoid SQL write contention
for ( auto& p : filesToAdd )
m_ml->onDiscoveredFile( p, parentFolder, parentFolderFs, m_probe->getPlaylistParent() );
m_ml->onDiscoveredFile( p, parentFolder, parentFolderFs,
IFile::Type::Main, m_probe->getPlaylistParent() );
t->commit();
LOG_INFO( "Done checking files in ", parentFolderFs->mrl() );
}, std::move( files ), std::move( filesToAdd ), std::move( filesToRefresh ) );
......
......@@ -62,17 +62,19 @@ FolderPtr MediaLibraryTester::folder( int64_t id ) const
std::shared_ptr<Media> MediaLibraryTester::addFile( const std::string& path, IMedia::Type type )
{
return addFile( std::make_shared<mock::NoopFile>( path ),
dummyFolder, dummyDirectory, type );
dummyFolder, dummyDirectory, IFile::Type::Main, type );
}
std::shared_ptr<Media> MediaLibraryTester::addFile( std::shared_ptr<fs::IFile> file, IMedia::Type type )
{
return addFile( std::move( file ), dummyFolder, dummyDirectory, type );
return addFile( std::move( file ), dummyFolder, dummyDirectory,
IFile::Type::Main, type );
}
std::shared_ptr<Media> MediaLibraryTester::addFile( std::shared_ptr<fs::IFile> fileFs,
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
IFile::Type fileType,
IMedia::Type type )
{
LOG_INFO( "Adding ", fileFs->mrl() );
......@@ -84,7 +86,8 @@ std::shared_ptr<Media> MediaLibraryTester::addFile( std::shared_ptr<fs::IFile> f
return nullptr;
}
// For now, assume all media are made of a single file
auto file = mptr->addFile( *fileFs, parentFolder->id(), parentFolderFs->device()->isRemovable(), File::Type::Main );
auto file = mptr->addFile( *fileFs, parentFolder->id(),
parentFolderFs->device()->isRemovable(), fileType );
if ( file == nullptr )
{
LOG_ERROR( "Failed to add file ", fileFs->mrl(), " to media #", mptr->id() );
......@@ -180,9 +183,10 @@ std::vector<const char*> MediaLibraryTester::getSupportedExtensions() const
void MediaLibraryTester::onDiscoveredFile(std::shared_ptr<fs::IFile> fileFs,
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
IFile::Type fileType,
std::pair<std::shared_ptr<Playlist>, unsigned int>)
{
addFile( fileFs, parentFolder, parentFolderFs, IMedia::Type::Unknown );
addFile( fileFs, parentFolder, parentFolderFs, fileType, IMedia::Type::Unknown );
}
sqlite::Connection* MediaLibraryTester::getDbConn()
......
......@@ -64,15 +64,16 @@ public:
std::shared_ptr<Media> addFile(const std::string& path , IMedia::Type type);
std::shared_ptr<Media> addFile( std::shared_ptr<fs::IFile> fileFs,
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
std::shared_ptr<fs::IDirectory> parentFolderFs, IFile::Type fileType,
IMedia::Type type );
virtual void addLocalFsFactory() override;
std::shared_ptr<Device> device( const std::string& uuid );
std::vector<const char*> getSupportedExtensions() const;
virtual void onDiscoveredFile( std::shared_ptr<fs::IFile> fileFs,
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
std::pair<std::shared_ptr<Playlist>, unsigned int> parentPlaylist ) override;
std::shared_ptr<Folder> parentFolder,
std::shared_ptr<fs::IDirectory> parentFolderFs,
IFile::Type fileType,
std::pair<std::shared_ptr<Playlist>, unsigned int> parentPlaylist ) override;
sqlite::Connection* getDbConn();
virtual void startThumbnailer() override;
virtual void populateNetworkFsFactories() 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