Skip to content

Commit

Permalink
Fix --update behaviour in mythfilldatabase after b7a1bd2
Browse files Browse the repository at this point in the history
This also deprecates --update in favour of the clearer
--only-update-guide which does the same job but is more descriptive
and mirrors --only-update-channels
  • Loading branch information
stuartm committed Sep 8, 2013
1 parent a166efd commit cd14631
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
28 changes: 16 additions & 12 deletions mythtv/programs/mythfilldatabase/channeldata.cpp
Expand Up @@ -323,38 +323,42 @@ void ChannelData::handleChannels(int id, ChannelInfoList *chanlist)
cout << "### " << endl;
}
}
else if ((dbChan.icon != localfile) ||
(dbChan.xmltvid != (*i).xmltvid))
else if (!m_guideDataOnly &&
((dbChan.icon != localfile) ||
(dbChan.xmltvid != (*i).xmltvid)))
{
LOG(VB_XMLTV, LOG_NOTICE, QString("Updating channel %1 (%2)")
.arg(dbChan.name).arg(dbChan.chanid));
if (!m_nonUSUpdating && !localfile.isEmpty())

if (localfile.isEmpty())
localfile = dbChan.icon;

if (dbChan.xmltvid != (*i).xmltvid)
{
MSqlQuery subquery(MSqlQuery::InitCon());
subquery.prepare("UPDATE channel SET icon = :ICON WHERE "

subquery.prepare("UPDATE channel SET icon = :ICON "
", xmltvid:= :XMLTVID WHERE "
"chanid = :CHANID;");
subquery.bindValue(":ICON", localfile);
subquery.bindValue(":XMLTVID", (*i).xmltvid);
subquery.bindValue(":CHANID", dbChan.chanid);

if (!subquery.exec())
MythDB::DBError("Channel icon change", subquery);
}
else
{
if (localfile.isEmpty())
localfile = dbChan.icon;
MSqlQuery subquery(MSqlQuery::InitCon());

subquery.prepare("UPDATE channel SET icon = :ICON "
", xmltvid:= :XMLTVID WHERE "
subquery.prepare("UPDATE channel SET icon = :ICON WHERE "
"chanid = :CHANID;");
subquery.bindValue(":ICON", localfile);
subquery.bindValue(":XMLTVID", (*i).xmltvid);
subquery.bindValue(":CHANID", dbChan.chanid);

if (!subquery.exec())
MythDB::DBError("Channel icon change", subquery);
}

}
}
else if (insert_chan(id)) // Only insert channels for non-scannable sources
Expand Down Expand Up @@ -418,10 +422,10 @@ void ChannelData::handleChannels(int id, ChannelInfoList *chanlist)
cout << "### " << endl;
}
}
else if (!m_nonUSUpdating && ((minor == 0) || (freq > 0)))
else if (!m_guideDataOnly && ((minor == 0) || (freq > 0)))
{
// We only do this if we are not asked to skip it with the
// --updating flag.
// --update-guide-only (formerly --update) flag.
int mplexid = 0, chanid = 0;
if (minor > 0)
{
Expand Down
4 changes: 2 additions & 2 deletions mythtv/programs/mythfilldatabase/channeldata.h
Expand Up @@ -11,7 +11,7 @@ class ChannelData
{
public:
ChannelData() :
m_interactive(false), m_nonUSUpdating(false),
m_interactive(false), m_guideDataOnly(false),
m_channelPreset(false), m_channelUpdates(false),
m_removeNewChannels(false), m_filterNewChannels(true) {}

Expand All @@ -27,7 +27,7 @@ class ChannelData

public:
bool m_interactive;
bool m_nonUSUpdating;
bool m_guideDataOnly;
bool m_channelPreset;
bool m_channelUpdates;
bool m_removeNewChannels;
Expand Down
21 changes: 15 additions & 6 deletions mythtv/programs/mythfilldatabase/commandlineparser.cpp
Expand Up @@ -18,12 +18,6 @@ void MythFillDatabaseCommandLineParser::LoadArguments(void)
"Manual mode will interactively ask you questions about "
"each channel as it is processed, to configure for "
"future use.");
add("--update", "update", false, "Run non-destructive updates",
"Run non-destructive updates on the database for "
"users in xmltv zones that do not provide channel "
"data. Stops the addition of new channels and the "
"changing of channel icons.")
->SetBlocks("manual");

add("--preset", "preset", false,
"Use channel preset values instead of numbers",
Expand Down Expand Up @@ -63,6 +57,21 @@ void MythFillDatabaseCommandLineParser::LoadArguments(void)
->SetRequiredChildOf("ddfile")
->SetRequiredChildOf("file");


add("--update", "update", false, "Run non-destructive updates",
"Run non-destructive updates on the database for "
"users in xmltv zones that do not provide channel "
"data. Stops the addition of new channels and the "
"changing of channel icons.")
->SetBlocks("manual")
->SetDeprecated("Use --only-update-guide instead.")
->SetGroup("Guide Data Handling");
add("--only-update-guide", "onlyguide", false, "Only update guide data",
"Only update the guide data, do not alter channels or icons.")
->SetBlocks("manual")
->SetGroup("Guide Data Handling");


add("--do-channel-updates", "dochannelupdates", false,
"update channels using datadirect",
"When using DataDirect, ask mythfilldatabase to "
Expand Down
12 changes: 4 additions & 8 deletions mythtv/programs/mythfilldatabase/main.cpp
Expand Up @@ -112,15 +112,11 @@ int main(int argc, char *argv[])
fill_data.chan_data.m_interactive = true;
}

if (cmdline.toBool("update"))
if (cmdline.toBool("onlyguide") && cmdline.toBool("update"))
{
if (cmdline.toBool("manual"))
{
cerr << "--update and --manual cannot be used simultaneously"
<< endl;
return GENERIC_EXIT_INVALID_CMDLINE;
}
fill_data.chan_data.m_nonUSUpdating = true;
LOG(VB_GENERAL, LOG_NOTICE,
"Only updating guide data, channel and icon updates will be ignored");
fill_data.chan_data.m_guideDataOnly = true;
}

if (cmdline.toBool("preset"))
Expand Down

0 comments on commit cd14631

Please sign in to comment.