[DB] Catch permission file errors when updating
This commit is contained in:
@@ -589,44 +589,53 @@ Updater::processDirectory(const boost::filesystem::path& rootDirectory,
|
|||||||
bool
|
bool
|
||||||
Updater::checkFile(const boost::filesystem::path& p, const std::vector<boost::filesystem::path>& rootDirs, const std::vector<boost::filesystem::path>& extensions)
|
Updater::checkFile(const boost::filesystem::path& p, const std::vector<boost::filesystem::path>& rootDirs, const std::vector<boost::filesystem::path>& extensions)
|
||||||
{
|
{
|
||||||
bool status = true;
|
try
|
||||||
|
{
|
||||||
|
bool status = true;
|
||||||
|
|
||||||
// For each track, make sure the the file still exists
|
// For each track, make sure the the file still exists
|
||||||
// and still belongs to a root directory
|
// and still belongs to a root directory
|
||||||
if (!boost::filesystem::exists( p )
|
if (!boost::filesystem::exists( p )
|
||||||
|| !boost::filesystem::is_regular( p ) )
|
|| !boost::filesystem::is_regular( p ) )
|
||||||
{
|
|
||||||
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Missing file '" << p << "'";
|
|
||||||
status = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool foundRoot = false;
|
|
||||||
BOOST_FOREACH(const boost::filesystem::path& rootDir, rootDirs)
|
|
||||||
{
|
{
|
||||||
if (p.string().find( rootDir.string() ) != std::string::npos)
|
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Missing file '" << p << "'";
|
||||||
|
status = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool foundRoot = false;
|
||||||
|
BOOST_FOREACH(const boost::filesystem::path& rootDir, rootDirs)
|
||||||
{
|
{
|
||||||
foundRoot = true;
|
if (p.string().find( rootDir.string() ) != std::string::npos)
|
||||||
break;
|
{
|
||||||
|
foundRoot = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundRoot)
|
||||||
|
{
|
||||||
|
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Out of root file '" << p << "'";
|
||||||
|
status = false;
|
||||||
|
}
|
||||||
|
else if (!isFileSupported(p, extensions))
|
||||||
|
{
|
||||||
|
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "File format no longer supported for '" << p << "'";
|
||||||
|
status = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundRoot)
|
return status;
|
||||||
{
|
|
||||||
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Out of root file '" << p << "'";
|
}
|
||||||
status = false;
|
catch (boost::filesystem::filesystem_error& e)
|
||||||
}
|
{
|
||||||
else if (!isFileSupported(p, extensions))
|
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Caught exception while checking file '" << p << "': " << e.what();
|
||||||
{
|
return false;
|
||||||
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "File format no longer supported for '" << p << "'";
|
|
||||||
status = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Updater::checkAudioFiles( Stats& stats )
|
Updater::checkAudioFiles( Stats& stats )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user