Better handling of index updates

We first try to create entry and update it if fails. Using get_or_create
is wrong here as it leads to more race conditions and also is slower as
we usually want to create new entry here.

Fixes #551

Signed-off-by: Michal Čihař <michal@cihar.com>