Skip to content

Commit

Permalink
RecordingInfo::InsertProgram: Create recgroup if it doesn't already e…
Browse files Browse the repository at this point in the history
…xist.
  • Loading branch information
jpoet committed Dec 12, 2024
1 parent 20a721d commit 166ce70
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mythtv/libs/libmythtv/recordinginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,26 @@ bool RecordingInfo::InsertProgram(RecordingInfo *pg,
return false;
}

// Catchall - in the event that the group doesn't exist, then to avoid
// breakage, we need to create it
if (recgroupid == 0)
{
query.prepare("INSERT INTO recgroups SET recgroup = :NAME, "
"displayname = :DISPLAYNAME");
query.bindValue(":NAME", pg->m_recGroup);
query.bindValue(":DISPLAYNAME", pg->m_recGroup);

if (query.exec())
recgroupid = query.lastInsertId().toInt();

if (recgroupid <= 0)
{
LOG(VB_GENERAL, LOG_ERR, QString("Could not create recording group (%1). "
"Does it already exist?")
.arg(pg->m_recGroup));
}
}

query.prepare(
"SELECT recordid "
" FROM recorded "
Expand Down

0 comments on commit 166ce70

Please sign in to comment.