mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 03:25:31 -05:00
correct emergency regeneration in the controller
This commit is contained in:
parent
2625c3bb9a
commit
0f53fc8328
3 changed files with 6 additions and 3 deletions
|
@ -5,6 +5,7 @@ class StylesheetsController < ApplicationController
|
||||||
|
|
||||||
target,digest = params[:name].split("_")
|
target,digest = params[:name].split("_")
|
||||||
|
|
||||||
|
digest_orig = digest
|
||||||
digest = "_" + digest if digest
|
digest = "_" + digest if digest
|
||||||
|
|
||||||
# Security note, safe due to route constraint
|
# Security note, safe due to route constraint
|
||||||
|
@ -13,7 +14,7 @@ class StylesheetsController < ApplicationController
|
||||||
unless File.exist?(location)
|
unless File.exist?(location)
|
||||||
query = StylesheetCache.where(target: target)
|
query = StylesheetCache.where(target: target)
|
||||||
if digest
|
if digest
|
||||||
query = query.where(digest: digest)
|
query = query.where(digest: digest_orig)
|
||||||
else
|
else
|
||||||
query = query.order('id desc')
|
query = query.order('id desc')
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,9 @@ class StylesheetCache < ActiveRecord::Base
|
||||||
count = StylesheetCache.count
|
count = StylesheetCache.count
|
||||||
if count > MAX_TO_KEEP
|
if count > MAX_TO_KEEP
|
||||||
|
|
||||||
remove_lower = StylesheetCache.limit(MAX_TO_KEEP)
|
remove_lower = StylesheetCache
|
||||||
|
.where(target: target)
|
||||||
|
.limit(MAX_TO_KEEP)
|
||||||
.order('id desc')
|
.order('id desc')
|
||||||
.pluck(:id)
|
.pluck(:id)
|
||||||
.last
|
.last
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe StylesheetCache do
|
||||||
describe "add" do
|
describe "add" do
|
||||||
it "correctly cycles once MAX_TO_KEEP is hit" do
|
it "correctly cycles once MAX_TO_KEEP is hit" do
|
||||||
(StylesheetCache::MAX_TO_KEEP + 1).times do |i|
|
(StylesheetCache::MAX_TO_KEEP + 1).times do |i|
|
||||||
StylesheetCache.add(i.to_s, "d" + i.to_s, "c" + i.to_s)
|
StylesheetCache.add("a", "d" + i.to_s, "c" + i.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(StylesheetCache.count).to eq StylesheetCache::MAX_TO_KEEP
|
expect(StylesheetCache.count).to eq StylesheetCache::MAX_TO_KEEP
|
||||||
|
|
Loading…
Reference in a new issue