Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2016-09-29 16:18:15 +0300
committerPatricio Cano <suprnova32@gmail.com>2016-09-29 18:25:26 +0300
commit26678d8ea3f05b5508c0ebc80cb2bc40e0a66556 (patch)
tree463e42504cd7eb1b963f07090e42dc1c9c06403e /lib/gitlab/lfs_token.rb
parent33d1f5904ce94cf2295b94aba6099a502be4b852 (diff)
Fix race condition that can be triggered if the token expires right after we retrieve it, but before we can set the new expiry time.
Diffstat (limited to 'lib/gitlab/lfs_token.rb')
-rw-r--r--lib/gitlab/lfs_token.rb9
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/gitlab/lfs_token.rb b/lib/gitlab/lfs_token.rb
index 7b3bbcf6a32..5f67e97fa2a 100644
--- a/lib/gitlab/lfs_token.rb
+++ b/lib/gitlab/lfs_token.rb
@@ -20,13 +20,8 @@ module Gitlab
def token
Gitlab::Redis.with do |redis|
token = redis.get(redis_key)
-
- if token
- redis.expire(redis_key, EXPIRY_TIME)
- else
- token = Devise.friendly_token(TOKEN_LENGTH)
- redis.set(redis_key, token, ex: EXPIRY_TIME)
- end
+ token ||= Devise.friendly_token(TOKEN_LENGTH)
+ redis.set(redis_key, token, ex: EXPIRY_TIME)
token
end