[DB] Better handling file errors
This commit is contained in:
@@ -96,15 +96,16 @@ std::vector<boost::filesystem::path>
|
|||||||
Grabber::getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t nbMaxCovers) const
|
Grabber::getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t nbMaxCovers) const
|
||||||
{
|
{
|
||||||
std::vector<boost::filesystem::path> res;
|
std::vector<boost::filesystem::path> res;
|
||||||
|
boost::system::error_code ec;
|
||||||
|
|
||||||
// TODO handle preferred file names
|
// TODO handle preferred file names
|
||||||
|
|
||||||
boost::filesystem::directory_iterator itPath(directoryPath);
|
boost::filesystem::directory_iterator itPath(directoryPath, ec);
|
||||||
boost::filesystem::directory_iterator itEnd;
|
boost::filesystem::directory_iterator itEnd;
|
||||||
while (itPath != itEnd)
|
while (!ec && itPath != itEnd)
|
||||||
{
|
{
|
||||||
boost::filesystem::path path = *itPath;
|
boost::filesystem::path path = *itPath;
|
||||||
itPath++;
|
itPath.increment(ec);
|
||||||
|
|
||||||
if (!boost::filesystem::is_regular(path))
|
if (!boost::filesystem::is_regular(path))
|
||||||
continue;
|
continue;
|
||||||
@@ -122,7 +123,6 @@ Grabber::getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t
|
|||||||
if (res.size() >= nbMaxCovers)
|
if (res.size() >= nbMaxCovers)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -585,35 +585,35 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
|||||||
void
|
void
|
||||||
Updater::processRootDirectory(RootDirectory rootDirectory, Stats& stats)
|
Updater::processRootDirectory(RootDirectory rootDirectory, Stats& stats)
|
||||||
{
|
{
|
||||||
|
boost::system::error_code ec;
|
||||||
|
|
||||||
if (!boost::filesystem::exists(rootDirectory.path) || !boost::filesystem::is_directory(rootDirectory.path))
|
boost::filesystem::recursive_directory_iterator itPath(rootDirectory.path, ec);
|
||||||
return;
|
|
||||||
|
|
||||||
boost::filesystem::recursive_directory_iterator itPath(rootDirectory.path);
|
|
||||||
boost::filesystem::recursive_directory_iterator itEnd;
|
boost::filesystem::recursive_directory_iterator itEnd;
|
||||||
while (itPath != itEnd)
|
while (!ec && itPath != itEnd)
|
||||||
{
|
{
|
||||||
|
boost::filesystem::path path = *itPath;
|
||||||
|
itPath.increment(ec);
|
||||||
|
|
||||||
if (!_running)
|
if (!_running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (boost::filesystem::is_regular(*itPath))
|
if (boost::filesystem::is_regular(path))
|
||||||
{
|
{
|
||||||
switch( rootDirectory.type )
|
switch( rootDirectory.type )
|
||||||
{
|
{
|
||||||
case Database::MediaDirectory::Audio:
|
case Database::MediaDirectory::Audio:
|
||||||
if (isFileSupported(*itPath, _audioFileExtensions))
|
if (isFileSupported(path, _audioFileExtensions))
|
||||||
processAudioFile( *itPath, stats );
|
processAudioFile(path, stats );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Database::MediaDirectory::Video:
|
case Database::MediaDirectory::Video:
|
||||||
if (isFileSupported(*itPath, _videoFileExtensions))
|
if (isFileSupported(path, _videoFileExtensions))
|
||||||
processVideoFile( *itPath, stats);
|
processVideoFile(path, stats);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++itPath;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user