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:
parent
7242293c25
commit
4ffca659cc
1 changed files with 3 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue