r17723 - in /branches/upstream/libnet-amazon-s3-perl/current: CHANGES META.yml Makefile.PL README lib/Net/Amazon/S3.pm lib/Net/Amazon/S3/Bucket.pm t/01api.t

roberto at users.alioth.debian.org roberto at users.alioth.debian.org
Mon Mar 17 03:12:05 UTC 2008


Author: roberto
Date: Mon Mar 17 03:12:04 2008
New Revision: 17723

URL: http://svn.debian.org/wsvn/?sc=1&rev=17723
Log:
[svn-upgrade] Integrating new upstream version, libnet-amazon-s3-perl (0.43)

Modified:
    branches/upstream/libnet-amazon-s3-perl/current/CHANGES
    branches/upstream/libnet-amazon-s3-perl/current/META.yml
    branches/upstream/libnet-amazon-s3-perl/current/Makefile.PL
    branches/upstream/libnet-amazon-s3-perl/current/README
    branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3.pm
    branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3/Bucket.pm
    branches/upstream/libnet-amazon-s3-perl/current/t/01api.t

Modified: branches/upstream/libnet-amazon-s3-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/branches/upstream/libnet-amazon-s3-perl/current/CHANGES?rev=17723&op=diff
==============================================================================
--- branches/upstream/libnet-amazon-s3-perl/current/CHANGES (original)
+++ branches/upstream/libnet-amazon-s3-perl/current/CHANGES Mon Mar 17 03:12:04 2008
@@ -1,4 +1,11 @@
 Revision history for Perl module Net::Amazon::S3:
+
+0.43 Sat Mar  1 10:55:54 GMT 2008
+     - add binmode() to support Windows (thanks to Gabriel Weinberg)
+
+0.42 Thu Feb 28 06:39:59 GMT 2008
+     - add exponential backoff upon temporary errors with the new
+       retry option
 
 0.41 Fri Nov 30 10:42:26 GMT 2007
      - fix the expensive tests (patch by BDOLAN)

Modified: branches/upstream/libnet-amazon-s3-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libnet-amazon-s3-perl/current/META.yml?rev=17723&op=diff
==============================================================================
--- branches/upstream/libnet-amazon-s3-perl/current/META.yml (original)
+++ branches/upstream/libnet-amazon-s3-perl/current/META.yml Mon Mar 17 03:12:04 2008
@@ -1,11 +1,11 @@
 --- #YAML:1.0
 name:                Net-Amazon-S3
-version:             0.41
+version:             0.43
 abstract:            ~
 license:             perl
 author:              
     - Leon Brocard <acme at astray.com>
-generated_by:        ExtUtils::MakeMaker version 6.38
+generated_by:        ExtUtils::MakeMaker version 6.42
 distribution_type:   module
 requires:     
     Class::Accessor::Fast:         0
@@ -13,7 +13,7 @@
     Digest::HMAC_SHA1:             0
     Digest::MD5::File:             0
     HTTP::Date:                    0
-    LWP::UserAgent:                0
+    LWP::UserAgent::Determined:    0
     MIME::Base64:                  0
     Test::More:                    0.01
     URI::Escape:                   0

Modified: branches/upstream/libnet-amazon-s3-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libnet-amazon-s3-perl/current/Makefile.PL?rev=17723&op=diff
==============================================================================
--- branches/upstream/libnet-amazon-s3-perl/current/Makefile.PL (original)
+++ branches/upstream/libnet-amazon-s3-perl/current/Makefile.PL Mon Mar 17 03:12:04 2008
@@ -13,7 +13,7 @@
         'Digest::MD5::File'          => '0',
         'Digest::HMAC_SHA1'          => '0',
         'HTTP::Date'                 => '0',
-        'LWP::UserAgent'             => '0',
+        'LWP::UserAgent::Determined' => '0',
         'MIME::Base64'               => '0',
         'Test::More'                 => '0.01',
         'XML::LibXML'                => '0',

Modified: branches/upstream/libnet-amazon-s3-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libnet-amazon-s3-perl/current/README?rev=17723&op=diff
==============================================================================
--- branches/upstream/libnet-amazon-s3-perl/current/README (original)
+++ branches/upstream/libnet-amazon-s3-perl/current/README Mon Mar 17 03:12:04 2008
@@ -116,6 +116,11 @@
         How many seconds should your script wait before bailing on a request
         to S3? Defaults to 30.
 
+    retry
+        If this library should retry upon errors. This option is
+        recommended. This uses exponential backoff with retries after 1, 2,
+        4, 8, 16, 32 seconds, as recommended by Amazon.
+
   buckets
     Returns undef on error, else hashref of results
 
@@ -127,6 +132,12 @@
 
     acl_short (optional)
         See the set_acl subroutine for documenation on the acl_short options
+
+    location_constraint (option)
+        Sets the location constraint of the new bucket. If left unspecified,
+        the default S3 datacenter location will be used. Otherwise, you can
+        set it to 'EU' for a European data center - note that costs are
+        different.
 
     Returns 0 on failure, Net::Amazon::S3::Bucket object on success
 

Modified: branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3.pm?rev=17723&op=diff
==============================================================================
--- branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3.pm (original)
+++ branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3.pm Mon Mar 17 03:12:04 2008
@@ -15,6 +15,7 @@
   my $s3 = Net::Amazon::S3->new(
       {   aws_access_key_id     => $aws_access_key_id,
           aws_secret_access_key => $aws_secret_access_key,
+          retry                 => 1,
       }
   );
 
@@ -102,16 +103,16 @@
 use HTTP::Date;
 use MIME::Base64 qw(encode_base64);
 use Net::Amazon::S3::Bucket;
-use LWP::UserAgent;
+use LWP::UserAgent::Determined;
 use URI::Escape qw(uri_escape_utf8);
 use XML::LibXML;
 use XML::LibXML::XPathContext;
 
 use base qw(Class::Accessor::Fast);
 __PACKAGE__->mk_accessors(
-    qw(libxml aws_access_key_id aws_secret_access_key secure ua err errstr timeout)
+    qw(libxml aws_access_key_id aws_secret_access_key secure ua err errstr timeout retry)
 );
-our $VERSION = '0.41';
+our $VERSION = '0.43';
 
 my $AMAZON_HEADER_PREFIX = 'x-amz-';
 my $METADATA_PREFIX      = 'x-amz-meta-';
@@ -152,6 +153,12 @@
 How many seconds should your script wait before bailing on a request to S3? Defaults
 to 30.
 
+=item retry
+
+If this library should retry upon errors. This option is recommended.
+This uses exponential backoff with retries after 1, 2, 4, 8, 16, 32 seconds, 
+as recommended by Amazon. Defaults to off.
+
 =back
 
 =cut
@@ -166,12 +173,23 @@
     $self->secure(0)   if not defined $self->secure;
     $self->timeout(30) if not defined $self->timeout;
 
-    my $ua = LWP::UserAgent->new(
-        keep_alive            => $KEEP_ALIVE_CACHESIZE,
-        requests_redirectable => [qw(GET HEAD DELETE PUT)],
-    );
+    my $ua;
+    if ( $self->retry ) {
+        $ua = LWP::UserAgent::Determined->new(
+            keep_alive            => $KEEP_ALIVE_CACHESIZE,
+            requests_redirectable => [qw(GET HEAD DELETE PUT)],
+        );
+        $ua->timing('1,2,4,8,16,32');
+    } else {
+        $ua = LWP::UserAgent->new(
+            keep_alive            => $KEEP_ALIVE_CACHESIZE,
+            requests_redirectable => [qw(GET HEAD DELETE PUT)],
+        );
+    }
+
     $ua->timeout( $self->timeout );
     $ua->env_proxy;
+
     $self->ua($ua);
     $self->libxml( XML::LibXML->new );
     return $self;

Modified: branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3/Bucket.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3/Bucket.pm?rev=17723&op=diff
==============================================================================
--- branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3/Bucket.pm (original)
+++ branches/upstream/libnet-amazon-s3-perl/current/lib/Net/Amazon/S3/Bucket.pm Mon Mar 17 03:12:04 2008
@@ -3,6 +3,7 @@
 use warnings;
 use Carp;
 use File::stat;
+use IO::File;
 use base qw(Class::Accessor::Fast);
 __PACKAGE__->mk_accessors(qw(bucket creation_date account));
 
@@ -460,13 +461,23 @@
 
     croak "$filename not a readable file with fixed size"
         unless -r $filename and $remaining;
-    open DATA, "< $filename" or croak "Could not open $filename: $!";
+    my $fh = IO::File->new( $filename, 'r' )
+        or croak "Could not open $filename: $!";
+    $fh->binmode;
 
     return sub {
         my $buffer;
 
+        # upon retries the file is closed and we must reopen it
+        unless ( $fh->opened ) {
+            $fh = IO::File->new( $filename, 'r' )
+                or croak "Could not open $filename: $!";
+            $fh->binmode;
+            $remaining = $stat->size;
+        }
+
         # warn "read remaining $remaining";
-        unless ( my $read = read( DATA, $buffer, $blksize ) ) {
+        unless ( my $read = $fh->read( $buffer, $blksize ) ) {
 
 #                       warn "read $read buffer $buffer remaining $remaining";
             croak
@@ -474,7 +485,7 @@
                 if $! and $remaining;
 
             # otherwise, we found EOF
-            close DATA
+            $fh->close
                 or croak "close of upload content $filename failed: $!";
             $buffer ||= ''
                 ;    # LWP expects an emptry string on finish, read returns 0

Modified: branches/upstream/libnet-amazon-s3-perl/current/t/01api.t
URL: http://svn.debian.org/wsvn/branches/upstream/libnet-amazon-s3-perl/current/t/01api.t?rev=17723&op=diff
==============================================================================
--- branches/upstream/libnet-amazon-s3-perl/current/t/01api.t (original)
+++ branches/upstream/libnet-amazon-s3-perl/current/t/01api.t Mon Mar 17 03:12:04 2008
@@ -23,7 +23,8 @@
 
 my $s3 = Net::Amazon::S3->new(
     {   aws_access_key_id     => $aws_access_key_id,
-        aws_secret_access_key => $aws_secret_access_key
+        aws_secret_access_key => $aws_secret_access_key,
+        retry                 => 1,
     }
 );
 




More information about the Pkg-perl-cvs-commits mailing list