diff --git a/internal/registry/registry.go b/internal/registry/registry.go index a4f64a8..e911a8a 100644 --- a/internal/registry/registry.go +++ b/internal/registry/registry.go @@ -94,13 +94,13 @@ func (r *registry) Update(user string, oldKey, newKey Key) error { return ErrInvalidSlug } + r.mu.Lock() + defer r.mu.Unlock() + if _, exists := r.slugIndex[newKey]; exists && newKey != oldKey { return ErrSlugInUse } - r.mu.Lock() - defer r.mu.Unlock() - client, ok := r.byUser[user][oldKey] if !ok { return ErrSessionNotFound