diff --git a/src/cover/CoverArtGrabber.cpp b/src/cover/CoverArtGrabber.cpp index 1cfe38ef..5eed27fb 100644 --- a/src/cover/CoverArtGrabber.cpp +++ b/src/cover/CoverArtGrabber.cpp @@ -96,15 +96,16 @@ std::vector Grabber::getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t nbMaxCovers) const { std::vector res; + boost::system::error_code ec; // TODO handle preferred file names - boost::filesystem::directory_iterator itPath(directoryPath); + boost::filesystem::directory_iterator itPath(directoryPath, ec); boost::filesystem::directory_iterator itEnd; - while (itPath != itEnd) + while (!ec && itPath != itEnd) { boost::filesystem::path path = *itPath; - itPath++; + itPath.increment(ec); if (!boost::filesystem::is_regular(path)) continue; @@ -122,7 +123,6 @@ Grabber::getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t if (res.size() >= nbMaxCovers) break; } - return res; } diff --git a/src/database-updater/DatabaseUpdater.cpp b/src/database-updater/DatabaseUpdater.cpp index cd8582ca..179d882e 100644 --- a/src/database-updater/DatabaseUpdater.cpp +++ b/src/database-updater/DatabaseUpdater.cpp @@ -585,35 +585,35 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats) void Updater::processRootDirectory(RootDirectory rootDirectory, Stats& stats) { + boost::system::error_code ec; - if (!boost::filesystem::exists(rootDirectory.path) || !boost::filesystem::is_directory(rootDirectory.path)) - return; + boost::filesystem::recursive_directory_iterator itPath(rootDirectory.path, ec); - boost::filesystem::recursive_directory_iterator itPath(rootDirectory.path); boost::filesystem::recursive_directory_iterator itEnd; - while (itPath != itEnd) + while (!ec && itPath != itEnd) { + boost::filesystem::path path = *itPath; + itPath.increment(ec); + if (!_running) return; - if (boost::filesystem::is_regular(*itPath)) + if (boost::filesystem::is_regular(path)) { switch( rootDirectory.type ) { case Database::MediaDirectory::Audio: - if (isFileSupported(*itPath, _audioFileExtensions)) - processAudioFile( *itPath, stats ); + if (isFileSupported(path, _audioFileExtensions)) + processAudioFile(path, stats ); break; case Database::MediaDirectory::Video: - if (isFileSupported(*itPath, _videoFileExtensions)) - processVideoFile( *itPath, stats); + if (isFileSupported(path, _videoFileExtensions)) + processVideoFile(path, stats); break; } } - - ++itPath; } }