Skip to content

Commit 9a2c639

Browse files
authored
Merge pull request rails#42446 from nateberkopec/no-exceptions
Fix hot-path raising in ActionDispatch::Static
2 parents ba4fde3 + 5a2cea2 commit 9a2c639

File tree

1 file changed

+2
-5
lines changed
  • actionpack/lib/action_dispatch/middleware

1 file changed

+2
-5
lines changed

actionpack/lib/action_dispatch/middleware/static.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,8 @@ def try_precompressed_files(filepath, headers, accept_encoding:)
137137
end
138138

139139
def file_readable?(path)
140-
file_stat = File.stat(File.join(@root, path.b))
141-
rescue SystemCallError
142-
false
143-
else
144-
file_stat.file? && file_stat.readable?
140+
file_path = File.join(@root, path.b)
141+
File.file?(file_path) && File.readable?(file_path)
145142
end
146143

147144
def compressible?(content_type)

0 commit comments

Comments
 (0)