From d4b98b103ba0d583da6a73fc347f8fe34d0d7c1a Mon Sep 17 00:00:00 2001 From: Phan Le Date: Mon, 20 Apr 2015 10:52:07 -0700 Subject: [PATCH] There might be still a small chance that the file was deleted between checking it is readable and actually reading it --- lib/sass/cache_stores/filesystem.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/sass/cache_stores/filesystem.rb b/lib/sass/cache_stores/filesystem.rb index eea7c53749..caf6920bf7 100644 --- a/lib/sass/cache_stores/filesystem.rb +++ b/lib/sass/cache_stores/filesystem.rb @@ -17,12 +17,12 @@ def initialize(cache_location) # @see Base#\_retrieve def _retrieve(key, version, sha) return unless File.readable?(path_to(key)) - File.open(path_to(key), "rb") do |f| - if f.readline("\n").strip == version && f.readline("\n").strip == sha - return f.read - end - end begin + File.open(path_to(key), "rb") do |f| + if f.readline("\n").strip == version && f.readline("\n").strip == sha + return f.read + end + end File.unlink path_to(key) rescue Errno::ENOENT # Already deleted. Race condition?