SpacePermissionManager.savePermission can create duplicate records

The following API call does not verify if a user already has the specific permission. If it already has it, it creates duplicate records in the database.

In the UI if you would remove the permissions for this user and save the page, then the next record from the database is shown, confusing the user. If there are 2 records in the database than after two times deleting the permissions from the UI it’s really gone but you can imagine that running scripts migrating permissions, could end up in a lot of records showing the same permissions.

I also found there’s not really an update permission call so what is best practice here, to check if the permission already exists and then don’t do anything?

                            space, user