Refactored how filter tags are handled in the scan settings
This commit is contained in:
@@ -74,6 +74,7 @@ namespace Scanner
|
||||
{
|
||||
removeOrphanTracks(context);
|
||||
removeOrphanClusters();
|
||||
removeOrphanClusterTypes();
|
||||
removeOrphanArtists();
|
||||
removeOrphanReleases();
|
||||
}
|
||||
@@ -152,6 +153,12 @@ namespace Scanner
|
||||
removeOrphanEntries<Database::Cluster>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanClusterTypes()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan cluster types...");
|
||||
removeOrphanEntries<Database::ClusterType>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanArtists()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan artists...");
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Scanner
|
||||
|
||||
void removeOrphanTracks(ScanContext& context);
|
||||
void removeOrphanClusters();
|
||||
void removeOrphanClusterTypes();
|
||||
void removeOrphanArtists();
|
||||
void removeOrphanReleases();
|
||||
bool checkFile(const std::filesystem::path& p);
|
||||
|
||||
@@ -241,9 +241,9 @@ namespace Scanner
|
||||
{
|
||||
auto clusterType = ClusterType::find(session, tag);
|
||||
if (!clusterType)
|
||||
continue;
|
||||
clusterType = session.create<ClusterType>(tag);
|
||||
|
||||
for (auto clusterName : values)
|
||||
for (const auto& clusterName : values)
|
||||
{
|
||||
auto cluster = clusterType->getCluster(clusterName);
|
||||
if (!cluster)
|
||||
@@ -279,7 +279,10 @@ namespace Scanner
|
||||
|
||||
void ScanStepScanFiles::process(ScanContext& context)
|
||||
{
|
||||
_metadataParser->setClusterTypeNames(_settings.clusterTypeNames);
|
||||
std::vector<std::string> tagsToParse{ _tagsToParse };
|
||||
tagsToParse.insert(std::end(tagsToParse), std::cbegin(_settings.extraTags), std::cend(_settings.extraTags));
|
||||
|
||||
_metadataParser->setExtraTags(tagsToParse);
|
||||
|
||||
context.currentStepStats.totalElems = context.stats.filesScanned;
|
||||
|
||||
|
||||
@@ -20,24 +20,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "metadata/IParser.hpp"
|
||||
#include "ScanStepBase.hpp"
|
||||
|
||||
namespace Scanner
|
||||
{
|
||||
class ScanStepScanFiles : public ScanStepBase
|
||||
{
|
||||
public:
|
||||
ScanStepScanFiles(InitParams& initParams);
|
||||
class ScanStepScanFiles : public ScanStepBase
|
||||
{
|
||||
public:
|
||||
ScanStepScanFiles(InitParams& initParams);
|
||||
|
||||
private:
|
||||
ScanStep getStep() const override { return ScanStep::ScanningFiles; }
|
||||
std::string_view getStepName() const override { return "Scanning files"; }
|
||||
void process(ScanContext& context) override;
|
||||
private:
|
||||
ScanStep getStep() const override { return ScanStep::ScanningFiles; }
|
||||
std::string_view getStepName() const override { return "Scanning files"; }
|
||||
void process(ScanContext& context) override;
|
||||
|
||||
void scanAudioFile(const std::filesystem::path& file, ScanContext& context);
|
||||
void scanAudioFile(const std::filesystem::path& file, ScanContext& context);
|
||||
|
||||
std::unique_ptr<MetaData::IParser> _metadataParser;
|
||||
};
|
||||
std::unique_ptr<MetaData::IParser> _metadataParser;
|
||||
const std::vector<std::string> _tagsToParse{ "GENRE", "MOOD", "LANGUAGE", "ALBUMGROUPING" };
|
||||
};
|
||||
}
|
||||
|
||||
@@ -361,14 +361,10 @@ namespace Scanner
|
||||
}
|
||||
newSettings.mediaDirectory = scanSettings->getMediaDirectory();
|
||||
|
||||
const auto clusterTypes = scanSettings->getClusterTypes();
|
||||
std::set<std::string> clusterTypeNames;
|
||||
|
||||
std::transform(std::cbegin(clusterTypes), std::cend(clusterTypes),
|
||||
std::inserter(clusterTypeNames, clusterTypeNames.begin()),
|
||||
[](const ClusterType::pointer& clusterType) { return std::string{ clusterType->getName() }; });
|
||||
|
||||
newSettings.clusterTypeNames = std::move(clusterTypeNames);
|
||||
{
|
||||
const auto& tags{ scanSettings->getExtraTagsToScan() };
|
||||
std::transform(std::cbegin(tags), std::cend(tags), std::back_inserter(newSettings.extraTags), [](std::string_view tag) { return std::string{ tag };});
|
||||
}
|
||||
}
|
||||
|
||||
return newSettings;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <Wt/WDateTime.h>
|
||||
@@ -36,7 +35,7 @@ namespace Scanner
|
||||
std::vector<std::filesystem::path> supportedExtensions;
|
||||
std::filesystem::path mediaDirectory;
|
||||
bool skipDuplicateMBID {};
|
||||
std::set<std::string> clusterTypeNames;
|
||||
std::vector<std::string> extraTags;
|
||||
|
||||
bool operator==(const ScannerSettings& rhs) const
|
||||
{
|
||||
@@ -46,7 +45,7 @@ namespace Scanner
|
||||
&& supportedExtensions == rhs.supportedExtensions
|
||||
&& mediaDirectory == rhs.mediaDirectory
|
||||
&& skipDuplicateMBID == rhs.skipDuplicateMBID
|
||||
&& clusterTypeNames == rhs.clusterTypeNames;
|
||||
&& extraTags == rhs.extraTags;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user