Refactored namespaces
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "services/scanner/ScannerStats.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
class IScanStep
|
||||
{
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
#include "IScanStep.hpp"
|
||||
#include "ScannerSettings.hpp"
|
||||
|
||||
namespace Database
|
||||
namespace lms::db
|
||||
{
|
||||
class Db;
|
||||
}
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
class ScanStepBase : public IScanStep
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace Scanner
|
||||
const ScannerSettings& settings;
|
||||
ProgressCallback progressCallback;
|
||||
bool& abortScan;
|
||||
Database::Db& db;
|
||||
db::Db& db;
|
||||
};
|
||||
ScanStepBase(InitParams& initParams)
|
||||
: _settings {initParams.settings}
|
||||
@@ -56,6 +56,6 @@ namespace Scanner
|
||||
const ScannerSettings& _settings;
|
||||
ProgressCallback _progressCallback;
|
||||
bool& _abortScan;
|
||||
Database::Db& _db;
|
||||
db::Db& _db;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
#include "database/Db.hpp"
|
||||
#include "database/Session.hpp"
|
||||
#include "database/Track.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "core/ILogger.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
void ScanStepCheckDuplicatedDbFiles::process(ScanContext& context)
|
||||
{
|
||||
using namespace Database;
|
||||
using namespace db;
|
||||
|
||||
if (_abortScan)
|
||||
return;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "ScanStepBase.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
class ScanStepCheckDuplicatedDbFiles : public ScanStepBase
|
||||
{
|
||||
|
||||
@@ -21,14 +21,14 @@
|
||||
#include "database/Db.hpp"
|
||||
#include "database/Cluster.hpp"
|
||||
#include "database/Session.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
#include "core/ILogger.hpp"
|
||||
#include "core/Path.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
void ScanStepComputeClusterStats::process(ScanContext& context)
|
||||
{
|
||||
using namespace Database;
|
||||
using namespace db;
|
||||
|
||||
if (context.stats.nbChanges() == 0)
|
||||
return;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "ScanStepBase.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
class ScanStepComputeClusterStats : public ScanStepBase
|
||||
{
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
#include "ScanStepDiscoverFiles.hpp"
|
||||
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
#include "core/ILogger.hpp"
|
||||
#include "core/Path.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
void ScanStepDiscoverFiles::process(ScanContext& context)
|
||||
{
|
||||
@@ -31,12 +31,12 @@ namespace Scanner
|
||||
for (const ScannerSettings::MediaLibraryInfo& mediaLibrary : _settings.mediaLibraries)
|
||||
{
|
||||
std::size_t currentDirectoryProcessElemsCount{};
|
||||
PathUtils::exploreFilesRecursive(mediaLibrary.rootDirectory, [&](std::error_code ec, const std::filesystem::path& path)
|
||||
core::pathUtils::exploreFilesRecursive(mediaLibrary.rootDirectory, [&](std::error_code ec, const std::filesystem::path& path)
|
||||
{
|
||||
if (_abortScan)
|
||||
return false;
|
||||
|
||||
if (!ec && PathUtils::hasFileAnyExtension(path, _settings.supportedExtensions))
|
||||
if (!ec && core::pathUtils::hasFileAnyExtension(path, _settings.supportedExtensions))
|
||||
{
|
||||
context.currentStepStats.processedElems++;
|
||||
currentDirectoryProcessElemsCount++;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "ScanStepBase.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
class ScanStepDiscoverFiles : public ScanStepBase
|
||||
{
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
#include "database/Release.hpp"
|
||||
#include "database/Session.hpp"
|
||||
#include "database/Track.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
#include "core/ILogger.hpp"
|
||||
#include "core/Path.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
using namespace Database;
|
||||
using namespace db;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -81,7 +81,7 @@ namespace Scanner
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanTracks(ScanContext& context)
|
||||
{
|
||||
using namespace Database;
|
||||
using namespace db;
|
||||
|
||||
if (_abortScan)
|
||||
return;
|
||||
@@ -150,25 +150,25 @@ namespace Scanner
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanClusters()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan clusters...");
|
||||
removeOrphanEntries<Database::Cluster>(_db.getTLSSession(), _abortScan);
|
||||
removeOrphanEntries<db::Cluster>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanClusterTypes()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan cluster types...");
|
||||
removeOrphanEntries<Database::ClusterType>(_db.getTLSSession(), _abortScan);
|
||||
removeOrphanEntries<db::ClusterType>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanArtists()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan artists...");
|
||||
removeOrphanEntries<Database::Artist>(_db.getTLSSession(), _abortScan);
|
||||
removeOrphanEntries<db::Artist>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanReleases()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan releases...");
|
||||
removeOrphanEntries<Database::Release>(_db.getTLSSession(), _abortScan);
|
||||
removeOrphanEntries<db::Release>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
bool ScanStepRemoveOrphanDbFiles::checkFile(const std::filesystem::path& p)
|
||||
@@ -186,14 +186,14 @@ namespace Scanner
|
||||
if (std::none_of(std::cbegin(_settings.mediaLibraries), std::cend(_settings.mediaLibraries),
|
||||
[&](const ScannerSettings::MediaLibraryInfo& libraryInfo)
|
||||
{
|
||||
return PathUtils::isPathInRootPath(p, libraryInfo.rootDirectory, &excludeDirFileName);
|
||||
return core::pathUtils::isPathInRootPath(p, libraryInfo.rootDirectory, &excludeDirFileName);
|
||||
}))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO, "Removing '" << p.string() << "': out of media directory");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PathUtils::hasFileAnyExtension(p, _settings.supportedExtensions))
|
||||
if (!core::pathUtils::hasFileAnyExtension(p, _settings.supportedExtensions))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO, "Removing '" << p.string() << "': file format no longer handled");
|
||||
return false;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "ScanStepBase.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
class ScanStepRemoveOrphanDbFiles : public ScanStepBase
|
||||
{
|
||||
|
||||
@@ -30,19 +30,19 @@
|
||||
#include "database/TrackArtistLink.hpp"
|
||||
#include "metadata/Exception.hpp"
|
||||
#include "metadata/IParser.hpp"
|
||||
#include "utils/Exception.hpp"
|
||||
#include "utils/IConfig.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
#include "utils/ITraceLogger.hpp"
|
||||
#include "core/Exception.hpp"
|
||||
#include "core/IConfig.hpp"
|
||||
#include "core/ILogger.hpp"
|
||||
#include "core/Path.hpp"
|
||||
#include "core/ITraceLogger.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
using namespace Database;
|
||||
using namespace db;
|
||||
|
||||
namespace
|
||||
{
|
||||
Artist::pointer createArtist(Session& session, const MetaData::Artist& artistInfo)
|
||||
Artist::pointer createArtist(Session& session, const metadata::Artist& artistInfo)
|
||||
{
|
||||
Artist::pointer artist{ session.create<Artist>(artistInfo.name) };
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Scanner
|
||||
return artist;
|
||||
}
|
||||
|
||||
void updateArtistIfNeeded(Artist::pointer artist, const MetaData::Artist& artistInfo)
|
||||
void updateArtistIfNeeded(Artist::pointer artist, const metadata::Artist& artistInfo)
|
||||
{
|
||||
// Name may have been updated
|
||||
if (artist->getName() != artistInfo.name)
|
||||
@@ -69,11 +69,11 @@ namespace Scanner
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Artist::pointer> getOrCreateArtists(Session& session, const std::vector<MetaData::Artist>& artistsInfo, bool allowFallbackOnMBIDEntries)
|
||||
std::vector<Artist::pointer> getOrCreateArtists(Session& session, const std::vector<metadata::Artist>& artistsInfo, bool allowFallbackOnMBIDEntries)
|
||||
{
|
||||
std::vector<Artist::pointer> artists;
|
||||
|
||||
for (const MetaData::Artist& artistInfo : artistsInfo)
|
||||
for (const metadata::Artist& artistInfo : artistsInfo)
|
||||
{
|
||||
Artist::pointer artist;
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace Scanner
|
||||
return releaseType;
|
||||
}
|
||||
|
||||
void updateReleaseIfNeeded(Session& session, Release::pointer release, const MetaData::Release& releaseInfo)
|
||||
void updateReleaseIfNeeded(Session& session, Release::pointer release, const metadata::Release& releaseInfo)
|
||||
{
|
||||
if (release->getName() != releaseInfo.name)
|
||||
release.modify()->setName(releaseInfo.name);
|
||||
@@ -146,7 +146,7 @@ namespace Scanner
|
||||
}
|
||||
}
|
||||
|
||||
Release::pointer getOrCreateRelease(Session& session, const MetaData::Release& releaseInfo, const std::filesystem::path& expectedReleaseDirectory)
|
||||
Release::pointer getOrCreateRelease(Session& session, const metadata::Release& releaseInfo, const std::filesystem::path& expectedReleaseDirectory)
|
||||
{
|
||||
Release::pointer release;
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Scanner
|
||||
return Release::pointer{};
|
||||
}
|
||||
|
||||
std::vector<Cluster::pointer> getOrCreateClusters(Session& session, const MetaData::Track& track)
|
||||
std::vector<Cluster::pointer> getOrCreateClusters(Session& session, const metadata::Track& track)
|
||||
{
|
||||
std::vector<Cluster::pointer> clusters;
|
||||
|
||||
@@ -217,23 +217,23 @@ namespace Scanner
|
||||
return clusters;
|
||||
}
|
||||
|
||||
MetaData::ParserReadStyle getParserReadStyle()
|
||||
metadata::ParserReadStyle getParserReadStyle()
|
||||
{
|
||||
std::string_view readStyle{ Service<IConfig>::get()->getString("scanner-parser-read-style", "average") };
|
||||
std::string_view readStyle{ core::Service<core::IConfig>::get()->getString("scanner-parser-read-style", "average") };
|
||||
|
||||
if (readStyle == "fast")
|
||||
return MetaData::ParserReadStyle::Fast;
|
||||
return metadata::ParserReadStyle::Fast;
|
||||
else if (readStyle == "average")
|
||||
return MetaData::ParserReadStyle::Average;
|
||||
return metadata::ParserReadStyle::Average;
|
||||
else if (readStyle == "accurate")
|
||||
return MetaData::ParserReadStyle::Accurate;
|
||||
return metadata::ParserReadStyle::Accurate;
|
||||
|
||||
throw LmsException{ "Invalid value for 'scanner-parser-read-style'" };
|
||||
throw core::LmsException{ "Invalid value for 'scanner-parser-read-style'" };
|
||||
}
|
||||
|
||||
std::size_t getScanMetaDataThreadCount()
|
||||
{
|
||||
std::size_t threadCount{ Service<IConfig>::get()->getULong("scanner-metadata-thread-count", 0) };
|
||||
std::size_t threadCount{ core::Service<core::IConfig>::get()->getULong("scanner-metadata-thread-count", 0) };
|
||||
|
||||
if (threadCount == 0)
|
||||
threadCount = std::max<std::size_t>(std::thread::hardware_concurrency() / 2, 1);
|
||||
@@ -242,7 +242,7 @@ namespace Scanner
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ScanStepScanFiles::MetadataScanQueue::MetadataScanQueue(MetaData::IParser& parser, std::size_t threadCount, bool& abort)
|
||||
ScanStepScanFiles::MetadataScanQueue::MetadataScanQueue(metadata::IParser& parser, std::size_t threadCount, bool& abort)
|
||||
: _metadataParser{ parser }
|
||||
, _scanContextRunner{ _scanContext, threadCount, "ScannerMetadata" }
|
||||
, _abort{ abort }
|
||||
@@ -259,7 +259,7 @@ namespace Scanner
|
||||
{
|
||||
LMS_SCOPED_TRACE_OVERVIEW("Scanner", "AudioFileParseJob");
|
||||
|
||||
std::unique_ptr<MetaData::Track> track;
|
||||
std::unique_ptr<metadata::Track> track;
|
||||
|
||||
if (_abort)
|
||||
{
|
||||
@@ -272,7 +272,7 @@ namespace Scanner
|
||||
{
|
||||
track = _metadataParser.parse(path);
|
||||
}
|
||||
catch (const MetaData::Exception& e)
|
||||
catch (const metadata::Exception& e)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO, "Failed to parse '" << path.string() << "'");
|
||||
}
|
||||
@@ -323,7 +323,7 @@ namespace Scanner
|
||||
|
||||
ScanStepScanFiles::ScanStepScanFiles(InitParams& initParams)
|
||||
: ScanStepBase{ initParams }
|
||||
, _metadataParser{ MetaData::createParser(MetaData::ParserBackend::TagLib, getParserReadStyle()) } // For now, always use TagLib
|
||||
, _metadataParser{ metadata::createParser(metadata::ParserBackend::TagLib, getParserReadStyle()) } // For now, always use TagLib
|
||||
, _metadataScanQueue{ *_metadataParser, getScanMetaDataThreadCount(), _abortScan }
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO, "Using " << _metadataScanQueue.getThreadCount() << " thread(s) for scanning file metadata");
|
||||
@@ -347,7 +347,7 @@ namespace Scanner
|
||||
|
||||
for (const ScannerSettings::MediaLibraryInfo& mediaLibrary : _settings.mediaLibraries)
|
||||
{
|
||||
PathUtils::exploreFilesRecursive(mediaLibrary.rootDirectory, [&](std::error_code ec, const std::filesystem::path& path)
|
||||
core::pathUtils::exploreFilesRecursive(mediaLibrary.rootDirectory, [&](std::error_code ec, const std::filesystem::path& path)
|
||||
{
|
||||
LMS_SCOPED_TRACE_DETAILED("Scanner", "OnExploreFile");
|
||||
|
||||
@@ -359,7 +359,7 @@ namespace Scanner
|
||||
LMS_LOG(DBUPDATER, ERROR, "Cannot process entry '" << path.string() << "': " << ec.message());
|
||||
context.stats.errors.emplace_back(ScanError{ path, ScanErrorType::CannotReadFile, ec.message() });
|
||||
}
|
||||
else if (PathUtils::hasFileAnyExtension(path, _settings.supportedExtensions))
|
||||
else if (core::pathUtils::hasFileAnyExtension(path, _settings.supportedExtensions))
|
||||
{
|
||||
if (checkFileNeedScan(context, path, mediaLibrary))
|
||||
_metadataScanQueue.pushScanRequest(path);
|
||||
@@ -392,9 +392,9 @@ namespace Scanner
|
||||
Wt::WDateTime lastWriteTime;
|
||||
try
|
||||
{
|
||||
lastWriteTime = PathUtils::getLastWriteTime(file);
|
||||
lastWriteTime = core::pathUtils::getLastWriteTime(file);
|
||||
}
|
||||
catch (LmsException& e)
|
||||
catch (core::LmsException& e)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR, e.what());
|
||||
stats.skips++;
|
||||
@@ -405,7 +405,7 @@ namespace Scanner
|
||||
if (!context.forceScan)
|
||||
{
|
||||
// Skip file if last write is the same
|
||||
Database::Session& dbSession{ _db.getTLSSession() };
|
||||
db::Session& dbSession{ _db.getTLSSession() };
|
||||
auto transaction{ _db.getTLSSession().createReadTransaction() };
|
||||
|
||||
const Track::pointer track{ Track::findByPath(dbSession, file) };
|
||||
@@ -429,12 +429,12 @@ namespace Scanner
|
||||
|
||||
if (needUpdateLibrary)
|
||||
{
|
||||
Database::Session& dbSession{ _db.getTLSSession() };
|
||||
db::Session& dbSession{ _db.getTLSSession() };
|
||||
auto transaction{ _db.getTLSSession().createWriteTransaction() };
|
||||
|
||||
Track::pointer track{ Track::findByPath(dbSession, file) };
|
||||
assert(track);
|
||||
track.modify()->setMediaLibrary(Database::MediaLibrary::find(dbSession, libraryInfo.id)); // may be null, will be handled in the next scan anyway
|
||||
track.modify()->setMediaLibrary(db::MediaLibrary::find(dbSession, libraryInfo.id)); // may be null, will be handled in the next scan anyway
|
||||
stats.updates++;
|
||||
return false;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ namespace Scanner
|
||||
{
|
||||
LMS_SCOPED_TRACE_OVERVIEW("Scanner", "ProcessScanResults");
|
||||
|
||||
Database::Session& dbSession{ _db.getTLSSession() };
|
||||
db::Session& dbSession{ _db.getTLSSession() };
|
||||
auto transaction{ dbSession.createWriteTransaction() };
|
||||
|
||||
for (const MetaDataScanResult& scanResult : scanResults)
|
||||
@@ -471,22 +471,22 @@ namespace Scanner
|
||||
}
|
||||
}
|
||||
|
||||
void ScanStepScanFiles::processFileMetaData(ScanContext& context, const std::filesystem::path& file, const MetaData::Track& trackMetadata, const ScannerSettings::MediaLibraryInfo& libraryInfo)
|
||||
void ScanStepScanFiles::processFileMetaData(ScanContext& context, const std::filesystem::path& file, const metadata::Track& trackMetadata, const ScannerSettings::MediaLibraryInfo& libraryInfo)
|
||||
{
|
||||
ScanStats& stats{ context.stats };
|
||||
Wt::WDateTime lastWriteTime;
|
||||
try
|
||||
{
|
||||
lastWriteTime = PathUtils::getLastWriteTime(file);
|
||||
lastWriteTime = core::pathUtils::getLastWriteTime(file);
|
||||
}
|
||||
catch (LmsException& e)
|
||||
catch (core::LmsException& e)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR, e.what());
|
||||
stats.skips++;
|
||||
return;
|
||||
}
|
||||
|
||||
Database::Session& dbSession{ _db.getTLSSession() };
|
||||
db::Session& dbSession{ _db.getTLSSession() };
|
||||
Track::pointer track{ Track::findByPath(dbSession, file) };
|
||||
|
||||
if (trackMetadata.mbid && (!track || _settings.skipDuplicateMBID))
|
||||
@@ -519,7 +519,7 @@ namespace Scanner
|
||||
if (std::none_of(std::cbegin(_settings.mediaLibraries), std::cend(_settings.mediaLibraries),
|
||||
[&](const ScannerSettings::MediaLibraryInfo& libraryInfo)
|
||||
{
|
||||
return PathUtils::isPathInRootPath(file, libraryInfo.rootDirectory, &excludeDirFileName);
|
||||
return core::pathUtils::isPathInRootPath(file, libraryInfo.rootDirectory, &excludeDirFileName);
|
||||
}))
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include "metadata/IParser.hpp"
|
||||
#include "utils/IOContextRunner.hpp"
|
||||
#include "core/IOContextRunner.hpp"
|
||||
#include "ScanStepBase.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
class ScanStepScanFiles : public ScanStepBase
|
||||
{
|
||||
@@ -47,18 +47,18 @@ namespace Scanner
|
||||
struct MetaDataScanResult
|
||||
{
|
||||
std::filesystem::path path;
|
||||
std::unique_ptr<MetaData::Track> trackMetaData;
|
||||
std::unique_ptr<metadata::Track> trackMetaData;
|
||||
};
|
||||
void processMetaDataScanResults(ScanContext& context, std::span<const MetaDataScanResult> scanResults, const ScannerSettings::MediaLibraryInfo& libraryInfo);
|
||||
void processFileMetaData(ScanContext& context, const std::filesystem::path& file, const MetaData::Track& trackMetadata, const ScannerSettings::MediaLibraryInfo& libraryInfo);
|
||||
void processFileMetaData(ScanContext& context, const std::filesystem::path& file, const metadata::Track& trackMetadata, const ScannerSettings::MediaLibraryInfo& libraryInfo);
|
||||
|
||||
std::unique_ptr<MetaData::IParser> _metadataParser;
|
||||
std::unique_ptr<metadata::IParser> _metadataParser;
|
||||
const std::vector<std::string> _extraTagsToParse;
|
||||
|
||||
class MetadataScanQueue
|
||||
{
|
||||
public:
|
||||
MetadataScanQueue(MetaData::IParser& parser, std::size_t threadCount, bool& abort);
|
||||
MetadataScanQueue(metadata::IParser& parser, std::size_t threadCount, bool& abort);
|
||||
|
||||
std::size_t getThreadCount() const { return _scanContextRunner.getThreadCount(); }
|
||||
|
||||
@@ -70,9 +70,9 @@ namespace Scanner
|
||||
void wait(std::size_t maxScanRequestCount = 0); // wait until ongoing scan request count <= maxScanRequestCount
|
||||
|
||||
private:
|
||||
MetaData::IParser& _metadataParser;
|
||||
metadata::IParser& _metadataParser;
|
||||
boost::asio::io_context _scanContext;
|
||||
IOContextRunner _scanContextRunner;
|
||||
core::IOContextRunner _scanContextRunner;
|
||||
|
||||
mutable std::mutex _mutex ;
|
||||
std::size_t _ongoingScanCount{};
|
||||
|
||||
@@ -25,11 +25,10 @@
|
||||
#include "database/MediaLibrary.hpp"
|
||||
#include "database/TrackFeatures.hpp"
|
||||
#include "database/ScanSettings.hpp"
|
||||
#include "utils/Exception.hpp"
|
||||
#include "utils/IConfig.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
#include "utils/Tuple.hpp"
|
||||
#include "core/Exception.hpp"
|
||||
#include "core/IConfig.hpp"
|
||||
#include "core/ILogger.hpp"
|
||||
#include "core/Path.hpp"
|
||||
|
||||
#include "ScanStepCheckDuplicatedDbFiles.hpp"
|
||||
#include "ScanStepDiscoverFiles.hpp"
|
||||
@@ -37,9 +36,9 @@
|
||||
#include "ScanStepScanFiles.hpp"
|
||||
#include "ScanStepComputeClusterStats.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
using namespace Database;
|
||||
using namespace db;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -357,7 +356,7 @@ namespace Scanner
|
||||
{
|
||||
ScannerSettings newSettings;
|
||||
|
||||
newSettings.skipDuplicateMBID = Service<IConfig>::get()->getBool("scanner-skip-duplicate-mbid", false);
|
||||
newSettings.skipDuplicateMBID = core::Service<core::IConfig>::get()->getBool("scanner-skip-duplicate-mbid", false);
|
||||
{
|
||||
auto transaction{ _dbSession.createReadTransaction() };
|
||||
|
||||
@@ -371,7 +370,7 @@ namespace Scanner
|
||||
const auto fileExtensions{ scanSettings->getAudioFileExtensions() };
|
||||
newSettings.supportedExtensions.reserve(fileExtensions.size());
|
||||
std::transform(std::cbegin(fileExtensions), std::end(fileExtensions), std::back_inserter(newSettings.supportedExtensions),
|
||||
[](const std::filesystem::path& extension) { return std::filesystem::path{ StringUtils::stringToLower(extension.string()) }; });
|
||||
[](const std::filesystem::path& extension) { return std::filesystem::path{ core::stringUtils::stringToLower(extension.string()) }; });
|
||||
}
|
||||
|
||||
MediaLibrary::find(_dbSession, [&](const MediaLibrary::pointer& mediaLibrary)
|
||||
@@ -411,4 +410,4 @@ namespace Scanner
|
||||
notifyInProgress(stepStats);
|
||||
}
|
||||
|
||||
} // namespace Scanner
|
||||
} // namespace lms::scanner
|
||||
|
||||
@@ -34,16 +34,16 @@
|
||||
#include "database/Session.hpp"
|
||||
#include "database/Types.hpp"
|
||||
#include "services/scanner/IScannerService.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
#include "core/Path.hpp"
|
||||
#include "IScanStep.hpp"
|
||||
#include "ScannerSettings.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
class ScannerService : public IScannerService
|
||||
{
|
||||
public:
|
||||
ScannerService(Database::Db& db);
|
||||
ScannerService(db::Db& db);
|
||||
~ScannerService();
|
||||
|
||||
ScannerService(const ScannerService&) = delete;
|
||||
@@ -88,8 +88,8 @@ namespace Scanner
|
||||
boost::asio::system_timer _scheduleTimer{ _ioService };
|
||||
Events _events;
|
||||
std::chrono::system_clock::time_point _lastScanInProgressEmit{};
|
||||
Database::Db& _db;
|
||||
Database::Session _dbSession;
|
||||
db::Db& _db;
|
||||
db::Session _dbSession;
|
||||
|
||||
mutable std::shared_mutex _statusMutex;
|
||||
State _curState{ State::NotScheduled };
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
#include "database/MediaLibraryId.hpp"
|
||||
#include "database/ScanSettings.hpp"
|
||||
|
||||
namespace Scanner
|
||||
namespace lms::scanner
|
||||
{
|
||||
struct ScannerSettings
|
||||
{
|
||||
std::size_t scanVersion{};
|
||||
Wt::WTime startTime;
|
||||
Database::ScanSettings::UpdatePeriod updatePeriod{ Database::ScanSettings::UpdatePeriod::Never };
|
||||
db::ScanSettings::UpdatePeriod updatePeriod{ db::ScanSettings::UpdatePeriod::Never };
|
||||
std::vector<std::filesystem::path> supportedExtensions;
|
||||
bool skipDuplicateMBID{};
|
||||
std::vector<std::string> extraTags;
|
||||
@@ -41,7 +41,7 @@ namespace Scanner
|
||||
|
||||
struct MediaLibraryInfo
|
||||
{
|
||||
Database::MediaLibraryId id;
|
||||
db::MediaLibraryId id;
|
||||
std::filesystem::path rootDirectory;
|
||||
|
||||
bool operator<=>(const MediaLibraryInfo& other) const = default;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "services/scanner/ScannerStats.hpp"
|
||||
|
||||
namespace Scanner {
|
||||
namespace lms::scanner {
|
||||
|
||||
ScanError::ScanError(const std::filesystem::path& _file, ScanErrorType _error, const std::string& _systemError)
|
||||
: file {_file},
|
||||
@@ -46,5 +46,5 @@ ScanStepStats::progress() const
|
||||
return (processedElems / static_cast<float>(totalElems ? totalElems : 1)) * 100;
|
||||
}
|
||||
|
||||
} // namespace Scanner
|
||||
} // namespace lms::scanner
|
||||
|
||||
|
||||
Reference in New Issue
Block a user