sqlectron / sqlectron-core

https://sqlectron.github.io/
MIT License
221 stars 69 forks source link

rework validateUniqueId to not always pass #91

Closed MasterOdin closed 4 years ago

MasterOdin commented 4 years ago

In 93889f922efdc6050f873f636c37ff4cd925acf1, it was set-up that each entry in the server list must have a unique name to be used. This function was used to ensure that the new name for a server did not collide with the names of any other server. When 240e5f334fea120f90a65b38da90c9f6b60cc9d4 reworked it so that each server entry used a uuidv4 id instead, it made the the validateUniqueId function always returns and would never throw an exception.

This patch reworks it so that this function is only used when adding a server, and to make it return true/false until a unique id is generated that has not been used before. It's probable this function will never run more than once, but better be safe than sorry.

The check is removed from updating a server as the server id must exist and must be in the servers list, or else the very next line would not work.