Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
b0293d82
Commit
b0293d82
authored
Apr 18, 2017
by
David Haynes
🙆
Browse files
Merge branch 'nanderson-fixcollision' into '2.2-dev'
Fix collision resolution See merge request
!85
parents
c7362984
5bcb2200
Pipeline
#1252
passed with stage
in 1 minute and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
go/go/models.py
View file @
b0293d82
...
...
@@ -134,14 +134,13 @@ class URL(models.Model):
"""
if
cache
.
get
(
"hashids_counter"
)
is
None
:
cache
.
set
(
"hashids_counter"
,
URL
.
objects
.
count
())
cache
.
incr
(
"hashids_counter"
)
short
=
HASHIDS
.
encrypt
(
cache
.
get
(
"hashids_counter"
))
tries
=
1
while
tries
<
100
:
try
:
URL
.
objects
.
get
(
short__iexact
=
short
)
short
=
HASHIDS
.
encrypt
(
cache
.
get
(
"hashids_counter"
)
)
tries
+=
1
cache
.
incr
(
"hashids_counter"
)
URL
.
objects
.
get
(
short__iexact
=
short
)
except
URL
.
DoesNotExist
as
ex
:
print
(
ex
)
return
short
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment