diff options
Diffstat (limited to 'lib/mogilefs/new_file/common.rb')
-rw-r--r-- | lib/mogilefs/new_file/common.rb | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/mogilefs/new_file/common.rb b/lib/mogilefs/new_file/common.rb index e959a21..9b6511d 100644 --- a/lib/mogilefs/new_file/common.rb +++ b/lib/mogilefs/new_file/common.rb @@ -34,21 +34,21 @@ module MogileFS::NewFile::Common end def create_close(devid, uri, bytes_uploaded) - args = { - :fid => @opts[:fid], - :devid => devid, - :key => @opts[:key], - :domain => @opts[:domain], - :size => bytes_uploaded, - :path => uri.to_s, - } + dest_info = @opts[:info] ||= {} + dest_info["fid"] = @opts[:fid].to_i + dest_info["key"] = @opts[:key] + dest_info["domain"] = @opts[:domain] + dest_info[:devid] = devid + dest_info[:path] = uri.to_s + dest_info[:size] = bytes_uploaded if @md5 - args[:checksum] = "MD5:#{@md5.hexdigest}" + dest_info["checksum"] = "MD5:#{@md5.hexdigest}" elsif String === @opts[:content_md5] hex = @opts[:content_md5].unpack('m')[0].unpack('H*')[0] - args[:checksum] = "MD5:#{hex}" + dest_info["checksum"] = "MD5:#{hex}" end - args[:checksumverify] = 1 if @opts[:checksumverify] + + dest_info[:checksumverify] = 1 if @opts[:checksumverify] backend = @opts[:backend] # upload could've taken a long time, ping and try to ensure socket @@ -61,7 +61,16 @@ module MogileFS::NewFile::Common # twice will hurt us... backend.noop - backend.create_close(args) + backend.create_close(dest_info) + + # make this look like file_info + get_uris + dest_info.delete(:checksumverify) + dest_info.delete(:path) + dest_info[:uris] = [ uri ] + dest_info["devcount"] = 1 + dest_info["devids"] = [ dest_info.delete(:devid).to_i ] + dest_info["length"] = dest_info.delete(:size) + bytes_uploaded end |