From 231d1a91292f39d42df2317a2fe4eaa96fd68f41 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 22 Oct 2012 20:18:06 +0000 Subject: new_file allows optional :info hash to be populated This allows clients to avoid calling #file_info or #get_uris immediate after uploading a file to MogileFS. This can speed things up for cache-using clients with write-through caching. --- lib/mogilefs/mogilefs.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/mogilefs/mogilefs.rb') diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb index f5cb096..76325cb 100644 --- a/lib/mogilefs/mogilefs.rb +++ b/lib/mogilefs/mogilefs.rb @@ -244,6 +244,13 @@ class MogileFS::MogileFS < MogileFS::Client # Keep in mind most HTTP servers do not support HTTP trailers, so # passing a String is usually the safest way to use this. # + # [:info => Hash] + # + # This is an empty hash that will be filled the same information + # MogileFS::MogileFS#file_info. + # + # Additionally, it contains one additional key: :uris, + # an array of URI::HTTP objects to the stored destinations def new_file(key, args = nil, bytes = nil) # :yields: file raise MogileFS::ReadOnlyError if readonly? opts = { :key => key, :multi_dest => 1 } @@ -275,6 +282,7 @@ class MogileFS::MogileFS < MogileFS::Client opts[:content_length] ||= bytes if bytes opts[:new_file_max_time] ||= @new_file_max_time opts[:start_time] = Time.now + info = opts[:info] and info["class"] = klass || "default" case (dests[0][1] rescue nil) when %r{\Ahttp://} -- cgit v1.2.3-24-ge0c7