From 98c9559bf2854b2aefe8aa2aa15c66b4f7555fe7 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 22 Sep 2013 18:48:37 -0400 Subject: [PATCH] Delay initializing the s3 client until it's needed to silence warnings Signed-off-by: Shea Levy --- src/lib/Hydra/Plugin/S3Backup.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/Hydra/Plugin/S3Backup.pm b/src/lib/Hydra/Plugin/S3Backup.pm index a78a8ca0..4b3af23f 100644 --- a/src/lib/Hydra/Plugin/S3Backup.pm +++ b/src/lib/Hydra/Plugin/S3Backup.pm @@ -14,7 +14,7 @@ use Nix::Store; use Hydra::Model::DB; use Hydra::Helper::CatalystUtils; -my $client = Net::Amazon::S3::Client->new( s3 => Net::Amazon::S3->new( retry => 1 ) ); +my $client; my %compressors = ( xz => "| $Nix::Config::xz", bzip2 => "| $Nix::Config::bzip2", @@ -39,6 +39,9 @@ sub buildFinished { } return unless @matching_configs; + unless (defined $client) { + $client = Net::Amazon::S3::Client->new( s3 => Net::Amazon::S3->new( retry => 1 ) ); + } # !!! Maybe should do per-bucket locking? my $lockhandle = IO::File->new;