Better handler ClusterType creation
This commit is contained in:
@@ -385,18 +385,15 @@ MediaScanner::getClusters( const MetaData::Clusters& clustersNames)
|
|||||||
for (auto clusterNames : clustersNames)
|
for (auto clusterNames : clustersNames)
|
||||||
{
|
{
|
||||||
ClusterType::pointer clusterType = ClusterType::getByName(_db.getSession(), clusterNames.first);
|
ClusterType::pointer clusterType = ClusterType::getByName(_db.getSession(), clusterNames.first);
|
||||||
bool newType = !clusterType;
|
|
||||||
|
|
||||||
if (!clusterType)
|
if (!clusterType)
|
||||||
|
{
|
||||||
clusterType = ClusterType::create(_db.getSession(), clusterNames.first);
|
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)
|
for (auto clusterName : clusterNames.second)
|
||||||
{
|
{
|
||||||
Cluster::pointer cluster;
|
Cluster::pointer cluster = clusterType->getCluster(clusterName);
|
||||||
|
|
||||||
if (!newType)
|
|
||||||
cluster = clusterType->getCluster(clusterName);
|
|
||||||
|
|
||||||
if (!cluster)
|
if (!cluster)
|
||||||
cluster = Cluster::create(_db.getSession(), clusterType, clusterName);
|
cluster = Cluster::create(_db.getSession(), clusterType, clusterName);
|
||||||
|
|||||||
Reference in New Issue
Block a user