[DB] Better reporting database scan results (skipped, import errors)
This commit is contained in:
@@ -245,9 +245,10 @@ Updater::process(boost::system::error_code err)
|
||||
LMS_LOG(DBUPDATER, INFO) << "Processing root directory '" << rootDirectory.path << "' DONE";
|
||||
}
|
||||
|
||||
if (_running)
|
||||
checkDuplicatedAudioFiles(stats);
|
||||
|
||||
LMS_LOG(DBUPDATER, INFO) << "Scan complete. Changes = " << stats.nbChanges() << " (added = " << stats.nbAdded << ", nbRemoved = " << stats.nbRemoved << ", nbModified = " << stats.nbModified << "), Errors = " << stats.nbScanErrors;
|
||||
LMS_LOG(DBUPDATER, INFO) << "Scan complete. Scanned = " << stats.nbScanned << ", Skipped = " << stats.nbSkipped << ", Changes = " << stats.nbChanges() << " (added = " << stats.nbAdded << ", nbRemoved = " << stats.nbRemoved << ", nbModified = " << stats.nbModified << "), Scan errors = " << stats.nbScanErrors << ", Not imported = " << stats.nbNotImported;
|
||||
|
||||
// Update database stats
|
||||
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
|
||||
@@ -384,14 +385,18 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
||||
boost::posix_time::ptime lastWriteTime (boost::posix_time::from_time_t( boost::filesystem::last_write_time( file ) ) );
|
||||
|
||||
// Skip file if last write is the same
|
||||
// We chose not to compare
|
||||
{
|
||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||
|
||||
Wt::Dbo::ptr<Track> track = Track::getByPath(_db.getSession(), file);
|
||||
|
||||
if (track && track->getLastWriteTime() == lastWriteTime)
|
||||
{
|
||||
stats.nbSkipped++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MetaData::Items items;
|
||||
if (!_metadataParser.parse(file, items))
|
||||
@@ -400,6 +405,8 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
||||
return;
|
||||
}
|
||||
|
||||
stats.nbScanned++;
|
||||
|
||||
std::vector<unsigned char> checksum ;
|
||||
computeCrc(file, checksum);
|
||||
|
||||
@@ -421,7 +428,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
||||
track.remove();
|
||||
stats.nbRemoved++;
|
||||
}
|
||||
stats.nbScanErrors++;
|
||||
stats.nbNotImported++;
|
||||
return;
|
||||
}
|
||||
if (items.find(MetaData::Type::Duration) == items.end()
|
||||
@@ -435,13 +442,14 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
||||
track.remove();
|
||||
stats.nbRemoved++;
|
||||
}
|
||||
stats.nbScanErrors++;
|
||||
stats.nbNotImported++;
|
||||
return;
|
||||
}
|
||||
|
||||
// ***** Title
|
||||
std::string title;
|
||||
if (items.find(MetaData::Type::Title) != items.end()) {
|
||||
if (items.find(MetaData::Type::Title) != items.end())
|
||||
{
|
||||
title = boost::any_cast<std::string>(items[MetaData::Type::Title]);
|
||||
}
|
||||
else
|
||||
@@ -451,7 +459,6 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
||||
title = file.filename().string();
|
||||
}
|
||||
|
||||
|
||||
// ***** Genres
|
||||
std::vector< Genre::pointer > genres;
|
||||
{
|
||||
@@ -575,7 +582,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
Updater::processRootDirectory(RootDirectory rootDirectory, Stats& stats)
|
||||
{
|
||||
|
||||
@@ -781,11 +788,10 @@ Updater::checkVideoFiles( Stats& stats )
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Check video files done!";
|
||||
}
|
||||
|
||||
void
|
||||
Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
|
||||
{
|
||||
try {
|
||||
|
||||
// Check last update time
|
||||
boost::posix_time::ptime lastWriteTime (boost::posix_time::from_time_t( boost::filesystem::last_write_time( file ) ) );
|
||||
|
||||
@@ -797,7 +803,8 @@ Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
|
||||
return;
|
||||
|
||||
MetaData::Items items;
|
||||
_metadataParser.parse(file, items);
|
||||
if (!_metadataParser.parse(file, items))
|
||||
return;
|
||||
|
||||
// We estimate this is a video if:
|
||||
// - we found a least one video stream
|
||||
@@ -849,12 +856,6 @@ Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
|
||||
video.modify()->setLastWriteTime(lastWriteTime);
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
catch( std::exception& e )
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR) << "Exception while parsing video file : '" << file << "': '" << e.what() << "' => skipping!";
|
||||
stats.nbScanErrors++;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace DatabaseUpdater
|
||||
|
||||
@@ -44,10 +44,13 @@ class Updater
|
||||
|
||||
struct Stats
|
||||
{
|
||||
std::size_t nbSkipped = 0; // no change since last scan
|
||||
std::size_t nbScanned = 0;
|
||||
std::size_t nbScanErrors = 0; // cannot scan file
|
||||
std::size_t nbNotImported = 0; // Not imported (criteria not filled)
|
||||
std::size_t nbAdded = 0;
|
||||
std::size_t nbRemoved = 0;
|
||||
std::size_t nbModified = 0;
|
||||
std::size_t nbScanErrors = 0;
|
||||
|
||||
std::size_t nbChanges() const { return nbAdded + nbRemoved + nbModified;}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user