mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Add better error handling, correct the location on disk of stylesheet
This commit is contained in:
parent
eb244bac34
commit
ea670118c1
3 changed files with 8 additions and 2 deletions
|
@ -8,7 +8,7 @@ class StylesheetsController < ApplicationController
|
|||
digest = "_" + digest if digest
|
||||
|
||||
# Security note, safe due to route constraint
|
||||
location = "#{DiscourseStylesheets::CACHE_PATH}/#{target}#{digest}.css"
|
||||
location = "#{Rails.root}/#{DiscourseStylesheets::CACHE_PATH}/#{target}#{digest}.css"
|
||||
|
||||
unless File.exist?(location)
|
||||
query = StylesheetCache.where(target: target)
|
||||
|
|
|
@ -20,6 +20,8 @@ class StylesheetCache < ActiveRecord::Base
|
|||
success
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
false
|
||||
rescue PG::UniqueViolation
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -89,7 +89,11 @@ class DiscourseStylesheets
|
|||
File.open(stylesheet_fullpath, "w") do |f|
|
||||
f.puts css
|
||||
end
|
||||
StylesheetCache.add(@target, digest, css)
|
||||
begin
|
||||
StylesheetCache.add(@target, digest, css)
|
||||
rescue => e
|
||||
Rails.logger.warn "Completely unexpected error adding item to cache #{e}"
|
||||
end
|
||||
css
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue