mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Discouse.keep_readonly_mode
incorrect extends expiry.
This commit is contained in:
parent
2adae2a0b6
commit
bfa0f71e2b
|
@ -295,7 +295,7 @@ module Discourse
|
|||
# extend the expiry by 1 minute every 30 seconds
|
||||
unless Rails.env.test?
|
||||
Thread.new do
|
||||
while readonly_mode?
|
||||
while readonly_mode?(key)
|
||||
$redis.expire(key, READONLY_MODE_KEY_TTL)
|
||||
sleep 30.seconds
|
||||
end
|
||||
|
@ -309,8 +309,8 @@ module Discourse
|
|||
true
|
||||
end
|
||||
|
||||
def self.readonly_mode?
|
||||
recently_readonly? || $redis.mget(*READONLY_KEYS).compact.present?
|
||||
def self.readonly_mode?(keys = READONLY_KEYS)
|
||||
recently_readonly? || $redis.mget(*keys).compact.present?
|
||||
end
|
||||
|
||||
def self.last_read_only
|
||||
|
|
|
@ -177,6 +177,7 @@ describe Discourse do
|
|||
it "returns true when user enabled readonly mode key is present in redis" do
|
||||
Discourse.enable_readonly_mode(user_readonly_mode_key)
|
||||
expect(Discourse.readonly_mode?).to eq(true)
|
||||
expect(Discourse.readonly_mode?(readonly_mode_key)).to eq(false)
|
||||
|
||||
Discourse.disable_readonly_mode(user_readonly_mode_key)
|
||||
expect(Discourse.readonly_mode?).to eq(false)
|
||||
|
|
Loading…
Reference in New Issue
Block a user