Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
8bb7b158
Commit
8bb7b158
authored
5 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix find_next_generated_user_id_localpart
parent
9fb350af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/data_stores/main/registration.py
+7
-10
7 additions, 10 deletions
synapse/storage/data_stores/main/registration.py
with
7 additions
and
10 deletions
synapse/storage/data_stores/main/registration.py
+
7
−
10
View file @
8bb7b158
...
...
@@ -19,7 +19,6 @@ import logging
import
re
from
six
import
iterkeys
from
six.moves
import
range
from
twisted.internet
import
defer
from
twisted.internet.defer
import
Deferred
...
...
@@ -482,12 +481,8 @@ class RegistrationWorkerStore(SQLBaseStore):
"""
Gets the localpart of the next generated user ID.
Generated user IDs are integers, and we aim for them to be as small as
we can. Unfortunately, it
'
s possible some of them are already taken by
existing users, and there may be gaps in the already taken range. This
function returns the start of the first allocatable gap. This is to
avoid the case of ID 1000 being pre-allocated and starting at 1001 while
0-999 are available.
Generated user IDs are integers, so we find the largest integer user ID
already taken and return that plus one.
"""
def
_find_next_generated_user_id
(
txn
):
...
...
@@ -503,9 +498,11 @@ class RegistrationWorkerStore(SQLBaseStore):
match
=
regex
.
search
(
user_id
)
if
match
:
found
.
add
(
int
(
match
.
group
(
1
)))
for
i
in
range
(
len
(
found
)
+
1
):
if
i
not
in
found
:
return
i
if
not
found
:
return
1
return
max
(
found
)
+
1
return
(
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment