1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Don't read entire file into memory when saving to local blob storage. (local files)

We are using the local blobstore as a backend for concurrent uploads and
observed that memory was leaking quite quickly as GC cannot keep up.

So here, when the dest, src are  both local files, instead of calling
File.read, simply copy the file.
This commit is contained in:
Jamie Paton 2014-02-24 14:01:05 -08:00
parent 7242293c25
commit 4ffca659cc

View file

@ -1,3 +1,4 @@
require 'fileutils'
require 'fog/core/model'
module Fog
@ -103,6 +104,8 @@ module Fog
file = ::File.new(path, 'wb')
if body.is_a?(String)
file.write(body)
elsif body.kind_of? ::File and File.exists?(body.path)
FileUtils.cp(body.path, path)
else
file.write(body.read)
end