- Panasonic: fixed error reading lists with channels that refer to non-existing transponders

- Philips ChannelMap_45: incrementing fav list version number when saving and setting the last_watched_channel_id to
  the first channel in the fav list (ensuring that the channel is actually present in the list)
This commit is contained in:
Horst Beham
2021-02-17 09:41:06 +01:00
parent 241f8be0f7
commit f85ff02a92
3 changed files with 17 additions and 5 deletions

View File

@@ -1005,14 +1005,14 @@ namespace ChanSort.Loader.Philips
{
cmd.CommandText = $"delete from FavoriteChannels where fav_list_id={favListId}";
cmd.ExecuteNonQuery();
sqlInsertOrUpdateList = "update List set list_name=@name where list_id=@id";
sqlInsertOrUpdateList = "update List set list_name=@name, list_version=list_version+1 where list_id=@id";
}
else
{
favListId = favListIndexToId.Count == 0 ? 1 : favListIndexToId.Max() + 1;
favListIndexToId[favListIndex] = favListId;
favListIdToIndex[favListId] = favListIndex;
sqlInsertOrUpdateList = "insert into List (list_id, list_name) values (@id,@name)";
sqlInsertOrUpdateList = "insert into List (list_id, list_name, list_version) values (@id,@name,1)";
}
cmd.CommandText = sqlInsertOrUpdateList;
@@ -1048,6 +1048,10 @@ namespace ChanSort.Loader.Philips
cmd.CommandText = "delete from List where list_id not in (select fav_list_id from FavoriteChannels)";
cmd.ExecuteNonQuery();
// make sure the last_watched_channel_id is valid in the list
cmd.CommandText = "update List set last_watched_channel_id=(select min(channel_id) from FavoriteChannels f where f.fav_list_id=List.list_id)";
cmd.ExecuteNonQuery();
trans.Commit();
conn.Close();
}