[DB] Added some stats on import errors
This commit is contained in:
@@ -220,19 +220,22 @@ Updater::process(boost::system::error_code err)
|
|||||||
checkAudioFiles(stats);
|
checkAudioFiles(stats);
|
||||||
checkVideoFiles(stats);
|
checkVideoFiles(stats);
|
||||||
|
|
||||||
typedef std::pair<boost::filesystem::path, Database::MediaDirectory::Type> RootDirectory;
|
|
||||||
std::vector<RootDirectory> rootDirectories;
|
std::vector<RootDirectory> rootDirectories;
|
||||||
{
|
{
|
||||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||||
std::vector<MediaDirectory::pointer> mediaDirectories = MediaDirectory::getAll(_db.getSession());
|
|
||||||
for (MediaDirectory::pointer directory : mediaDirectories)
|
for (MediaDirectory::pointer directory : MediaDirectory::getAll(_db.getSession()))
|
||||||
rootDirectories.push_back( std::make_pair( directory->getPath(), directory->getType() ));
|
rootDirectories.push_back( RootDirectory( directory->getType(), directory->getPath() ));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (RootDirectory rootDirectory : rootDirectories)
|
for (RootDirectory rootDirectory : rootDirectories)
|
||||||
processDirectory(rootDirectory.first, rootDirectory.first, rootDirectory.second, stats);
|
{
|
||||||
|
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Processing root directory '" << rootDirectory.path << "'...";
|
||||||
|
processRootDirectory(rootDirectory, stats);
|
||||||
|
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Processing root directory '" << rootDirectory.path << "' DONE";
|
||||||
|
}
|
||||||
|
|
||||||
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Changes = " << stats.nbChanges();
|
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Scan complete. Changes = " << stats.nbChanges() << ", Errors = " << stats.nbScanErrors;
|
||||||
|
|
||||||
// Update database stats
|
// Update database stats
|
||||||
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
|
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
|
||||||
@@ -540,33 +543,33 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
|||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
}
|
}
|
||||||
catch( std::exception& e ) {
|
catch( std::exception& e )
|
||||||
|
{
|
||||||
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Exception while parsing audio file : '" << file << "': '" << e.what() << "' => skipping!";
|
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Exception while parsing audio file : '" << file << "': '" << e.what() << "' => skipping!";
|
||||||
|
stats.nbRemoved++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Updater::processDirectory(const boost::filesystem::path& rootDirectory,
|
Updater::processRootDirectory(RootDirectory rootDirectory, Stats& stats)
|
||||||
const boost::filesystem::path& p,
|
|
||||||
Database::MediaDirectory::Type type,
|
|
||||||
Stats& stats)
|
|
||||||
{
|
{
|
||||||
if (!_running)
|
if (!_running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!boost::filesystem::exists(p) || !boost::filesystem::is_directory(p))
|
if (!boost::filesystem::exists(rootDirectory.path) || !boost::filesystem::is_directory(rootDirectory.path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boost::filesystem::recursive_directory_iterator itPath(rootDirectory);
|
boost::filesystem::recursive_directory_iterator itPath(rootDirectory.path);
|
||||||
boost::filesystem::recursive_directory_iterator itEnd;
|
boost::filesystem::recursive_directory_iterator itEnd;
|
||||||
while (itPath != itEnd)
|
while (itPath != itEnd)
|
||||||
{
|
{
|
||||||
if (!_running)
|
if (!_running)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (boost::filesystem::is_regular(*itPath)) {
|
if (!boost::filesystem::is_regular(*itPath))
|
||||||
switch( type )
|
{
|
||||||
|
switch( rootDirectory.type )
|
||||||
{
|
{
|
||||||
case Database::MediaDirectory::Audio:
|
case Database::MediaDirectory::Audio:
|
||||||
if (isFileSupported(*itPath, _audioExtensions))
|
if (isFileSupported(*itPath, _audioExtensions))
|
||||||
@@ -780,8 +783,10 @@ Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
|
|||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
}
|
}
|
||||||
catch( std::exception& e ) {
|
catch( std::exception& e )
|
||||||
|
{
|
||||||
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Exception while parsing video file : '" << file << "': '" << e.what() << "' => skipping!";
|
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Exception while parsing video file : '" << file << "': '" << e.what() << "' => skipping!";
|
||||||
|
stats.nbScanErrors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,15 +44,22 @@ class Updater
|
|||||||
|
|
||||||
struct Stats
|
struct Stats
|
||||||
{
|
{
|
||||||
std::size_t nbAdded;
|
std::size_t nbAdded = 0;
|
||||||
std::size_t nbRemoved;
|
std::size_t nbRemoved = 0;
|
||||||
std::size_t nbModified;
|
std::size_t nbModified = 0;
|
||||||
Stats() : nbAdded(0), nbRemoved(0), nbModified(0) {}
|
std::size_t nbScanErrors = 0;
|
||||||
|
|
||||||
void clear(void) { nbAdded = 0; nbRemoved = 0; nbModified = 0; }
|
|
||||||
std::size_t nbChanges() const { return nbAdded + nbRemoved + nbModified;}
|
std::size_t nbChanges() const { return nbAdded + nbRemoved + nbModified;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RootDirectory
|
||||||
|
{
|
||||||
|
Database::MediaDirectory::Type type;
|
||||||
|
boost::filesystem::path path;
|
||||||
|
|
||||||
|
RootDirectory(Database::MediaDirectory::Type t, boost::filesystem::path p) : type(t), path(p) {}
|
||||||
|
};
|
||||||
|
|
||||||
// Job handling
|
// Job handling
|
||||||
void processNextJob();
|
void processNextJob();
|
||||||
void scheduleScan(boost::posix_time::time_duration duration);
|
void scheduleScan(boost::posix_time::time_duration duration);
|
||||||
@@ -67,10 +74,7 @@ class Updater
|
|||||||
const std::vector<boost::filesystem::path>& extensions);
|
const std::vector<boost::filesystem::path>& extensions);
|
||||||
|
|
||||||
|
|
||||||
void processDirectory( const boost::filesystem::path& rootDirectory,
|
void processRootDirectory( RootDirectory rootDirectory, Stats& stats);
|
||||||
const boost::filesystem::path& directory,
|
|
||||||
Database::MediaDirectory::Type type,
|
|
||||||
Stats& stats);
|
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
Database::Artist::pointer getArtist( const boost::filesystem::path& file, const std::string& name, const std::string& MBID);
|
Database::Artist::pointer getArtist( const boost::filesystem::path& file, const std::string& name, const std::string& MBID);
|
||||||
|
|||||||
Reference in New Issue
Block a user