diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-12-11 08:47:39 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-12-11 08:55:29 +0000 |
commit | 3f342091cec9fcd5f99ba934444f17cd0c77de71 (patch) | |
tree | a6a40207d1938206b88c5fe3bd1757095ac67d54 /lib/mogilefs/mogilefs.rb | |
parent | 9d5f3208dab86837106b56f105af8bbb121f438a (diff) | |
download | mogilefs-client-3f342091cec9fcd5f99ba934444f17cd0c77de71.tar.gz |
This defaults to 1 hour (which matches the expiry time of a row in the MogileFS internal tempfile table).
Diffstat (limited to 'lib/mogilefs/mogilefs.rb')
-rw-r--r-- | lib/mogilefs/mogilefs.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb index 8a35168..005bb19 100644 --- a/lib/mogilefs/mogilefs.rb +++ b/lib/mogilefs/mogilefs.rb @@ -37,12 +37,16 @@ class MogileFS::MogileFS < MogileFS::Client # The timeout for get_file_data. Defaults to five seconds. attr_accessor :get_file_data_timeout + # The maximum allowed time for creating a new_file. Defaults to 1 hour. + attr_accessor :new_file_max_time + # Creates a new MogileFS::MogileFS instance. +args+ must include a key # :domain specifying the domain of this client. def initialize(args = {}) @domain = args[:domain] - @get_file_data_timeout = 5 + @get_file_data_timeout = args[:get_file_data_timeout] || 5 + @new_file_max_time = args[:new_file_max_time] || 3600.0 raise ArgumentError, "you must specify a domain" unless @domain @@ -178,6 +182,8 @@ class MogileFS::MogileFS < MogileFS::Client opts[:backend] = @backend opts[:fid] = res['fid'] opts[:content_length] ||= bytes if bytes + opts[:new_file_max_time] ||= @new_file_max_time + opts[:start_time] = Time.now case (dests[0][1] rescue nil) when %r{\Ahttp://} |