diff options
author | horchi <vdr@jwendel.de> | 2018-10-02 19:21:14 +0200 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2018-10-02 19:21:14 +0200 |
commit | bd6ac8b88a6e128ad8778aad89f5d8c3f31148de (patch) | |
tree | c5e044200fc3101d6d14452aadc04b524883281b /channelmap.c | |
parent | 1cbab41a38411ded875924d8b3cdaba68bafd574 (diff) | |
download | vdr-epg-daemon-bd6ac8b88a6e128ad8778aad89f5d8c3f31148de.tar.gz vdr-epg-daemon-bd6ac8b88a6e128ad8778aad89f5d8c3f31148de.tar.bz2 |
2018-10-02: version 1.1.143 (horchi)\n change: Fixed compile problem of epglv \n \n1.1.143
Diffstat (limited to 'channelmap.c')
-rw-r--r-- | channelmap.c | 65 |
1 files changed, 60 insertions, 5 deletions
diff --git a/channelmap.c b/channelmap.c index 9629227..c8a52d6 100644 --- a/channelmap.c +++ b/channelmap.c @@ -223,10 +223,7 @@ int cEpgd::updateMapRow(char* extid, const char* source, const char* chan, if (changed || insert) { tell(1, "Channel '%s' %s, source '%s', extid %s, merge %d", - chan, insert ? "inserted" : "updated", - source, - extid, - merge); + chan, insert ? "inserted" : "updated", source, extid, merge); mapDb->setValue("MERGESP", 0L); // reset mergesp! mapDb->setValue("UPDFLG", insert ? "I" : "U"); @@ -241,7 +238,7 @@ int cEpgd::updateMapRow(char* extid, const char* source, const char* chan, } else { - mapDb->setValue("UPDFLG", "S"); + mapDb->setValue("UPDFLG", "S"); // 'S'tay - no change } mapDb->store(); @@ -259,6 +256,64 @@ int cEpgd::applyChannelmapChanges() connection->startTransaction(); mapDb->clear(); + mapDb->setValue("UPDFLG", "D"); + + // search matching 'I'nserted rows for all 'D'eleted rows to check if only the channelid has changed + + for (int f = selectMapByUpdFlg->find(); f; f = selectMapByUpdFlg->fetch()) + { + std::string oldChannelId = mapDb->getStrValue("CHANNELID"); + + mapDb->setValue("UPDFLG", "I"); + + if (selectMapByExt->find()) + { + std::string newChannelId = mapDb->getStrValue("CHANNELID"); + + tell(0, "channelid '%s' was changed to '%s'", oldChannelId.c_str(), newChannelId.c_str()); + + // change the 'I'nserted row and remove the 'D'eleted row -> no further action is necessary later on + + mapDb->find(); + mapDb->setValue("UPDFLG", "S"); + mapDb->update(); + mapDb->deleteWhere("channelid = '%s' and extid = '%s' and source = '%s'", + oldChannelId.c_str(), mapDb->getStrValue("EXTERNALID"), mapDb->getStrValue("SOURCE")); + + // now patch tables with channelid field + + std::map<std::string, cDbTableDef*>::iterator t; + + for (t = dbDict.getFirstTableIterator(); t != dbDict.getTableEndIterator(); t++) + { + cDbTableDef* td = t->second; + + if (td->hasName("CHANNELMAP")) + continue; + + if (td->getField("CHANNELID", yes)) + { + tell(3, "Table '%s' has a channelid field", td->getName()); + + cDbTable* table = new cDbTable(connection, t->first.c_str()); + char* stmt; + + asprintf(&stmt, "update %s set %s = '%s' where %s = '%s'", + td->getName(), + table->getField("CHANNELID")->getDbName(), newChannelId.c_str(), + table->getField("CHANNELID")->getDbName(), oldChannelId.c_str()); + + tell(0, "Executing '%s'", stmt); + connection->query("%s", stmt); + + free(stmt); + delete table; + } + } + } + } + + mapDb->clear(); for (int f = selectAllMap->find(); f; f = selectAllMap->fetch()) { |