From 519b310a4964583270a1f31ca6a707ead9b022e2 Mon Sep 17 00:00:00 2001 From: emeric Date: Sun, 2 Sep 2018 14:01:35 +0200 Subject: [PATCH] Do not stop on first error while scanning files --- src/scanner/MediaScanner.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/scanner/MediaScanner.cpp b/src/scanner/MediaScanner.cpp index a7ed1094..85c94153 100644 --- a/src/scanner/MediaScanner.cpp +++ b/src/scanner/MediaScanner.cpp @@ -578,21 +578,31 @@ MediaScanner::scanMediaDirectory(boost::filesystem::path mediaDirectory, bool fo boost::system::error_code ec; boost::filesystem::recursive_directory_iterator itPath(mediaDirectory, ec); + if (ec) + { + LMS_LOG(DBUPDATER, ERROR) << "Cannot iterate over '" << mediaDirectory.string() << "': " << ec.message(); + return; + } boost::filesystem::recursive_directory_iterator itEnd; - while (!ec && itPath != itEnd) + while (itPath != itEnd) { boost::filesystem::path path = *itPath; - itPath.increment(ec); if (!_running) return; - if (boost::filesystem::is_regular(path)) + if (ec) + { + LMS_LOG(DBUPDATER, ERROR) << "Cannot process entry: " << ec.message(); + } + else if (boost::filesystem::is_regular(path)) { if (isFileSupported(path, _fileExtensions)) scanAudioFile(path, forceScan, stats ); } + + itPath.increment(ec); } }