Skip to content

A platform for community discussion. Free, open, simple.

FIX: Write stylesheet cache atomically (#28457)

David Taylor150f5694dcc8
diff --git a/app/controllers/stylesheets_controller.rb b/app/controllers/stylesheets_controller.rb
index 12a477122c5..272e1cbe251 100644
--- a/app/controllers/stylesheets_controller.rb
+++ b/app/controllers/stylesheets_controller.rb
@@ -71,7 +71,7 @@ class StylesheetsController < ApplicationController
unless File.exist?(location)
if current = query.pick(source_map ? :source_map : :content)
FileUtils.mkdir_p(cache_path)
- File.write(location, current)
+ Discourse::Utils.atomic_write_file(location, current)
else
raise Discourse::NotFound
end