genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
392 stars 155 forks source link

fixes new pid generation sorting existing pids. grouping fixes duplic… #261

Closed amselem closed 8 years ago

amselem commented 8 years ago

…ated pids.

remove unused imports.

genemars commented 8 years ago

I see that mainly the bug is that the list is not sorted. But I don't understand the need of a GroupBy? Also the OrderBy could it be just OrderBy(p => p.Address)?

amselem commented 8 years ago

The original bug created programs with duplicated Ids, so I ended with a program list with Ids: 1000, 1000,1000,1001..... I first implemented the sorting fix, but the loop assumed each Id is unique so it stopped at 2n element because the candidate Id (1001) != Program.Id (1000). So it returned 1001 as the new id wich is incorrect because it existed in the Program list. I guess you can remove the groupby and it will work for new or non corrupted installs but for me was necesary

genemars commented 8 years ago

ok I will then add the OrderBy to the old code.