Attempt to check why some files are missing
This commit is contained in:
@@ -61,6 +61,8 @@
|
||||
<message id="Lms.Admin.Database.Status.last-scan-not-available">Not available</message>
|
||||
<message id="Lms.Admin.Database.Status.last-scan-status">Scanned {1} files in {2} on {3} ({4} errors, {5} duplicates)</message>
|
||||
<message id="Lms.Admin.Database.Status.no-audio-track">No audio track</message>
|
||||
<message id="Lms.Admin.Database.Status.not-regular">Not a regular file</message>
|
||||
<message id="Lms.Admin.Database.Status.not-supported">File type not supported</message>
|
||||
<message id="Lms.Admin.Database.Status.same-hash">Duplicated file hash</message>
|
||||
<message id="Lms.Admin.Database.Status.same-mbid">Duplicated MBID</message>
|
||||
<message id="Lms.Admin.Database.Status.status">Status</message>
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
<message id="Lms.Admin.Database.Status.last-scan-not-available">Non disponible</message>
|
||||
<message id="Lms.Admin.Database.Status.last-scan-status">{1} fichiers scannés en {2} le {3} ({4} erreurs, {5} duplicatas)</message>
|
||||
<message id="Lms.Admin.Database.Status.no-audio-track">Pas de piste audio</message>
|
||||
<message id="Lms.Admin.Database.Status.not-regular">Fichier non régulier</message>
|
||||
<message id="Lms.Admin.Database.Status.not-supported">Type de fichier non supporté</message>
|
||||
<message id="Lms.Admin.Database.Status.same-hash">Hash dupliqué</message>
|
||||
<message id="Lms.Admin.Database.Status.same-mbid">MBID dupliqué</message>
|
||||
<message id="Lms.Admin.Database.Status.status">Statut</message>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <Wt/Dbo/WtSqlTraits.h>
|
||||
|
||||
#include "utils/Path.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/String.hpp"
|
||||
|
||||
@@ -62,11 +63,11 @@ ScanSettings::get(Session& session)
|
||||
return session.getDboSession().find<ScanSettings>();
|
||||
}
|
||||
|
||||
std::set<std::filesystem::path>
|
||||
std::unordered_set<std::filesystem::path>
|
||||
ScanSettings::getAudioFileExtensions() const
|
||||
{
|
||||
auto extensions = StringUtils::splitString(_audioFileExtensions, " ");
|
||||
return std::set<std::filesystem::path>(std::cbegin(extensions), std::cend(extensions));
|
||||
return std::unordered_set<std::filesystem::path>(std::cbegin(extensions), std::cend(extensions));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <Wt/Dbo/Dbo.h>
|
||||
#include <Wt/WTime.h>
|
||||
|
||||
#include "utils/Path.hpp"
|
||||
|
||||
namespace Database {
|
||||
|
||||
class ClusterType;
|
||||
@@ -59,7 +61,7 @@ class ScanSettings : public Wt::Dbo::Dbo<ScanSettings>
|
||||
Wt::WTime getUpdateStartTime() const { return _startTime; }
|
||||
UpdatePeriod getUpdatePeriod() const { return _updatePeriod; }
|
||||
std::vector<Wt::Dbo::ptr<ClusterType>> getClusterTypes() const;
|
||||
std::set<std::filesystem::path> getAudioFileExtensions() const;
|
||||
std::unordered_set<std::filesystem::path> getAudioFileExtensions() const;
|
||||
RecommendationEngineType getRecommendationEngineType() const { return _recommendationEngineType; }
|
||||
|
||||
// Setters
|
||||
|
||||
@@ -63,7 +63,7 @@ getNextFirstOfMonth(Wt::WDate current)
|
||||
}
|
||||
|
||||
bool
|
||||
isFileSupported(const std::filesystem::path& file, const std::set<std::filesystem::path>& extensions)
|
||||
isFileSupported(const std::filesystem::path& file, const std::unordered_set<std::filesystem::path>& extensions)
|
||||
{
|
||||
return (extensions.find(file.extension()) != extensions.end());
|
||||
}
|
||||
@@ -768,10 +768,26 @@ MediaScanner::scanMediaDirectory(const std::filesystem::path& mediaDirectory, bo
|
||||
LMS_LOG(DBUPDATER, ERROR) << "Cannot process entry '" << path.string() << "': " << ec.message();
|
||||
stats.errors.emplace_back(ScanError {path, ScanErrorType::CannotReadFile, ec.message()});
|
||||
}
|
||||
else if (std::filesystem::is_directory(path))
|
||||
{
|
||||
;
|
||||
}
|
||||
else if (std::filesystem::is_regular_file(path))
|
||||
{
|
||||
if (isFileSupported(path, _fileExtensions))
|
||||
{
|
||||
scanAudioFile(path, forceScan, stats );
|
||||
}
|
||||
else
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR) << "Skipped '" << path.string() << "': file not supported";
|
||||
stats.errors.emplace_back(ScanError {path, ScanErrorType::NotSupported});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR) << "Skipped '" << path.string() << "': not a regular file";
|
||||
stats.errors.emplace_back(ScanError {path, ScanErrorType::NotRegular});
|
||||
}
|
||||
|
||||
itPath.increment(ec);
|
||||
@@ -782,7 +798,7 @@ MediaScanner::scanMediaDirectory(const std::filesystem::path& mediaDirectory, bo
|
||||
|
||||
// Check if a file exists and is still in a media directory
|
||||
static bool
|
||||
checkFile(const std::filesystem::path& p, const std::filesystem::path& mediaDirectory, const std::set<std::filesystem::path>& extensions)
|
||||
checkFile(const std::filesystem::path& p, const std::filesystem::path& mediaDirectory, const std::unordered_set<std::filesystem::path>& extensions)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ class MediaScanner : public IMediaScanner
|
||||
std::size_t _scanVersion {};
|
||||
Wt::WTime _startTime;
|
||||
Database::ScanSettings::UpdatePeriod _updatePeriod {Database::ScanSettings::UpdatePeriod::Never};
|
||||
std::set<std::filesystem::path> _fileExtensions;
|
||||
std::unordered_set<std::filesystem::path> _fileExtensions;
|
||||
std::filesystem::path _mediaDirectory;
|
||||
Database::ScanSettings::RecommendationEngineType _recommendationEngineType;
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Scanner {
|
||||
CannotParseFile, // cannot parse file
|
||||
NoAudioTrack, // no audio track found
|
||||
BadDuration, // bad duration
|
||||
NotSupported, // not supported
|
||||
NotRegular,
|
||||
};
|
||||
|
||||
enum class DuplicateReason
|
||||
|
||||
@@ -34,3 +34,10 @@ bool ensureDirectory(const std::filesystem::path& dir);
|
||||
// Get the last write time since Epoch
|
||||
Wt::WDateTime getLastWriteTime(const std::filesystem::path& dir);
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<std::filesystem::path> {
|
||||
inline std::size_t operator()(const std::filesystem::path &path) const { return hash_value(path); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ class ReportResource : public Wt::WResource
|
||||
case Scanner::ScanErrorType::CannotParseFile: return Wt::WString::tr("Lms.Admin.Database.Status.cannot-parse-file");
|
||||
case Scanner::ScanErrorType::NoAudioTrack: return Wt::WString::tr("Lms.Admin.Database.Status.no-audio-track");
|
||||
case Scanner::ScanErrorType::BadDuration: return Wt::WString::tr("Lms.Admin.Database.Status.bad-duration");
|
||||
case Scanner::ScanErrorType::NotSupported: return Wt::WString::tr("Lms.Admin.Database.Status.not-supported");
|
||||
case Scanner::ScanErrorType::NotRegular: return Wt::WString::tr("Lms.Admin.Database.Status.not-regular");
|
||||
}
|
||||
return "?";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user