From 4ffca659cc3ba8578b9315a2bbe81a40078f94e8 Mon Sep 17 00:00:00 2001 From: Jamie Paton Date: Mon, 24 Feb 2014 14:01:05 -0800 Subject: [PATCH] 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. --- lib/fog/local/models/storage/file.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/fog/local/models/storage/file.rb b/lib/fog/local/models/storage/file.rb index cbad0231e..6e67a025c 100644 --- a/lib/fog/local/models/storage/file.rb +++ b/lib/fog/local/models/storage/file.rb @@ -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