lib/i18n/js/middleware.rb in i18n-js-3.0.0.rc14 vs lib/i18n/js/middleware.rb in i18n-js-3.0.0.rc15
- old
+ new
@@ -1,5 +1,7 @@
+require "fileutils"
+
module I18n
module JS
class Middleware
def initialize(app)
@app = app
@@ -30,10 +32,16 @@
end
end
end
def clear_cache
- File.delete(cache_path) if File.exist?(cache_path)
+ # `File.delete` will raise error when "multiple worker"
+ # Are running at the same time, like in a parallel test
+ #
+ # `FileUtils.rm_f` is tested manually
+ #
+ # See https://github.com/fnando/i18n-js/issues/436
+ FileUtils.rm_f(cache_path) if File.exist?(cache_path)
end
def save_cache(new_cache)
# path could be a symbolic link
FileUtils.mkdir_p(cache_dir) unless File.exists?(cache_dir)