A platform for community discussion. Free, open, simple.
FIX: race condition during deploys creating stylesheets
Sam Saffron0bf3316aec01
diff --git a/app/controllers/stylesheets_controller.rb b/app/controllers/stylesheets_controller.rbindex aa25b78ec91..e5474da2ddb 100644--- a/app/controllers/stylesheets_controller.rb+++ b/app/controllers/stylesheets_controller.rb@@ -57,7 +57,9 @@ class StylesheetsController < ApplicationController# Security note, safe due to route constraintunderscore_digest = digest ? "_" + digest : ""- location = "#{Rails.root}/#{Stylesheet::Manager::CACHE_PATH}/#{target}#{underscore_digest}#{extension}"++ cache_path = "#{Rails.root}/#{Stylesheet::Manager::CACHE_PATH}"+ location = "#{cache_path}/#{target}#{underscore_digest}#{extension}"stylesheet_time = query.pluck(:created_at).first@@ -71,6 +73,7 @@ class StylesheetsController < ApplicationControllerunless File.exist?(location)if current = query.limit(1).pluck(source_map ? :source_map : :content).first+ FileUtils.mkdir_p(cache_path)File.write(location, current)elseraise Discourse::NotFound