Method: Rack::Cache::EntityStore::Disk#write
- Defined in:
- lib/rack/cache/entitystore.rb
#write(body) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/rack/cache/entitystore.rb', line 122 def write(body) filename = ['buf', $$, Thread.current.object_id].join('-') temp_file = storage_path(filename) key, size = File.open(temp_file, 'wb') { |dest| slurp(body) { |part| dest.write(part) } } path = body_path(key) if File.exist?(path) File.unlink temp_file else FileUtils.mkdir_p File.dirname(path), :mode => 0755 FileUtils.mv temp_file, path end [key, size] end |