2014-01-22, 12:30
I've just discovered that EPG database seems to be useless at least on loading PVR data on XBMC start.
For example, let's take a use case for one PVR client with one channel. The flow contains the following steps:
0. EPG DB is empty.
1. Load channel "Channel1" and its EPG from client.
2. Put the EPG to database. "epg" table contains now one record: "idEpg=1 name=Channel1" and "epgtags" contains records linked to idEpg=1.
3. CEpgContainer::m_epgs contains one item for idEpg=1.
4. Restart XBMC.
5. Load EPG from DB => CEpgContainer::m_epgs = {1: Channel1 EPG}.
6. Load EPG from client creates the new CEpg object with new idEpg=2.
7. Put EPG to database. "epg" tables contains two records: "idEpg=1 name=Channel1", "idEpg=2 name=Channel1", and in "epgtags" we have duplicate items for these EPGs.
8. CEpgContainer::m_epgs contains two items: CEpgContainer::m_epgs = {1: Channel1 EPG from DB, 2: Channel1 EPG from client}. The first one doesn't have CPVRChannel pointer and the second one used only.
9. Cleanup database => delete idEpg=1 and all linked records.
10. Restart XBMC.
11. Goto 5.
According to the flow the previous database entries for EPG are never used.
To fix this there must be a way to identify EPG for a channel. For example, adding clientId and channelId identifiers to "epg" table will do the thing.
Before creating the PR I'd like to know if this is a bug indeed or I'm missing something?
For example, let's take a use case for one PVR client with one channel. The flow contains the following steps:
0. EPG DB is empty.
1. Load channel "Channel1" and its EPG from client.
2. Put the EPG to database. "epg" table contains now one record: "idEpg=1 name=Channel1" and "epgtags" contains records linked to idEpg=1.
3. CEpgContainer::m_epgs contains one item for idEpg=1.
4. Restart XBMC.
5. Load EPG from DB => CEpgContainer::m_epgs = {1: Channel1 EPG}.
6. Load EPG from client creates the new CEpg object with new idEpg=2.
7. Put EPG to database. "epg" tables contains two records: "idEpg=1 name=Channel1", "idEpg=2 name=Channel1", and in "epgtags" we have duplicate items for these EPGs.
8. CEpgContainer::m_epgs contains two items: CEpgContainer::m_epgs = {1: Channel1 EPG from DB, 2: Channel1 EPG from client}. The first one doesn't have CPVRChannel pointer and the second one used only.
9. Cleanup database => delete idEpg=1 and all linked records.
10. Restart XBMC.
11. Goto 5.
According to the flow the previous database entries for EPG are never used.
To fix this there must be a way to identify EPG for a channel. For example, adding clientId and channelId identifiers to "epg" table will do the thing.
Before creating the PR I'd like to know if this is a bug indeed or I'm missing something?