From bbb988266def7679d3e9ae5796c16bb2611c0611 Mon Sep 17 00:00:00 2001 From: emeric Date: Sun, 4 Mar 2018 15:52:16 +0100 Subject: [PATCH] Better handler ClusterType creation --- src/scanner/MediaScanner.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/scanner/MediaScanner.cpp b/src/scanner/MediaScanner.cpp index e4b12f43..5c1b6e2e 100644 --- a/src/scanner/MediaScanner.cpp +++ b/src/scanner/MediaScanner.cpp @@ -385,18 +385,15 @@ MediaScanner::getClusters( const MetaData::Clusters& clustersNames) for (auto clusterNames : clustersNames) { ClusterType::pointer clusterType = ClusterType::getByName(_db.getSession(), clusterNames.first); - bool newType = !clusterType; - if (!clusterType) + { clusterType = ClusterType::create(_db.getSession(), clusterNames.first); + _db.getSession().flush(); // Make sure the newly createdType has an id + } - std::cout << "Cluster type = " << clusterType.id() << "\n"; for (auto clusterName : clusterNames.second) { - Cluster::pointer cluster; - - if (!newType) - cluster = clusterType->getCluster(clusterName); + Cluster::pointer cluster = clusterType->getCluster(clusterName); if (!cluster) cluster = Cluster::create(_db.getSession(), clusterType, clusterName);