Sha256: 82af9eefbb4ccdd1a883fc871a401d6c7d948b941b4dd5eed208f4e66e1f100f
Contents?: true
Size: 572 Bytes
Versions: 6
Compression:
Stored size: 572 Bytes
Contents
module Thumbs class CacheWrite def initialize(app, cache_type = "resized") @app = app @cache_type = cache_type end def call(env) status, headers, body = @app.call(env) path = env["thumbs.#{@cache_type}_path"] if path && status == 200 tries = 0 begin File.open(path, "wb") {|f| f.write(body) } rescue Errno::ENOENT, IOError Dir.mkdir(File.dirname(path), 0755) retry if (tries += 1) == 1 end end [status, headers, body] end end end
Version data entries
6 entries across 6 versions & 1 rubygems