mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -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
|
digest = "_" + digest if digest
|
||||||
|
|
||||||
# Security note, safe due to route constraint
|
# 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)
|
unless File.exist?(location)
|
||||||
query = StylesheetCache.where(target: target)
|
query = StylesheetCache.where(target: target)
|
||||||
|
|
|
@ -20,6 +20,8 @@ class StylesheetCache < ActiveRecord::Base
|
||||||
success
|
success
|
||||||
rescue ActiveRecord::RecordNotUnique
|
rescue ActiveRecord::RecordNotUnique
|
||||||
false
|
false
|
||||||
|
rescue PG::UniqueViolation
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,7 +89,11 @@ class DiscourseStylesheets
|
||||||
File.open(stylesheet_fullpath, "w") do |f|
|
File.open(stylesheet_fullpath, "w") do |f|
|
||||||
f.puts css
|
f.puts css
|
||||||
end
|
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
|
css
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue