[s3-dev] bugfixes object creation / metadata store

Metalhead metalhead at metalhead.ws
Mon Dec 18 07:01:15 EST 2006


Hi,

 I've included a patch that fixes 2 bugs I've noticed.

The first bug occurs when the creation of a new S3Object is attempted; About.new
requires a hash as an argument. Fixed by adding the empty hash as the default
argument.

The second bug is also concerned with the creation of new objects; the metadata
of non-stored objects isn't saved because a new About object is created when the
object is stored. Fixed by introducing a new attribute that checks whether About
has been initialised.

Thanks,

Lars


diff -bru aws-s3-0.2.1/lib/aws/s3/object.rb aws-s3-0.2.1-mine/lib/aws/s3/object.rb
--- aws-s3-0.2.1/lib/aws/s3/object.rb	2006-12-04 07:03:00.000000000 +0100
+++ aws-s3-0.2.1-mine/lib/aws/s3/object.rb	2006-12-18 12:50:01.000000000 +0100
@@ -304,7 +304,7 @@
       end
       
       class About < Hash #:nodoc:
-        def initialize(headers)
+        def initialize(headers={})
           super()
           replace(headers)
           metadata
@@ -491,7 +491,12 @@
       #  # => 'audio/mpeg'
       #  some_object.store
       def about
-        stored? ? self.class.about(key, bucket.name) : About.new
+	  if stored? 
+	      self.class.about(key, bucket.name) 
+	  else
+	      attributes['about_initialized'] = true
+	      About.new
+	  end
       end
       memoized :about
       
@@ -561,7 +566,7 @@
       
       # Returns true if the current object has been stored on S3 yet.
       def stored?
-        !attributes['e_tag'].nil?
+        !attributes['e_tag'].nil? || attributes['about_initialized']
       end
       
       def ==(s3object) #:nodoc:

-- 
Old hackers never die:  young ones do.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/amazon-s3-dev/attachments/20061218/88bc6671/attachment.bin 


More information about the amazon-s3-dev mailing list