diff options
Diffstat (limited to 'lib/App/Glacier/Command/Get.pm')
-rw-r--r-- | lib/App/Glacier/Command/Get.pm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/App/Glacier/Command/Get.pm b/lib/App/Glacier/Command/Get.pm index 0d17659..82b32c8 100644 --- a/lib/App/Glacier/Command/Get.pm +++ b/lib/App/Glacier/Command/Get.pm @@ -157,12 +157,14 @@ sub run { exit(0); } if ($job->is_completed) { my $cache_file = $job->cache_file; if (-f $cache_file) { + $self->debug(1, "$job: copying from $cache_file"); + return if $self->dry_run; unless (copy($cache_file, $localname)) { $self->abend(EX_FAILURE, "can't copy $cache_file to $localname: $!"); } } else { my $tree_hash = $self->download($job, $localname); @@ -190,12 +192,13 @@ sub run { use constant MB => 1024*1024; use constant TWOMB => 2*MB; sub download { my ($self, $job, $localname) = @_; + my $archive_size = $job->get('ArchiveSizeInBytes'); if ($archive_size < $self->cf_transfer_param(qw(download single-part-size))) { # simple download $self->_download_simple($job, $localname); } else { $self->_download_multipart($job, $localname); @@ -211,15 +214,13 @@ sub _open_output { return $fd; } sub _download_simple { my ($self, $job, $localname) = @_; - eval { # FIXME: file_name might be absent - $self->debug(1, "downloading", $job->file_name(1), "in single part"); - }; + $self->debug(1, "$job: downloading in single part"); return if $self->dry_run; my $fd = $self->_open_output($localname); my ($res, $tree_hash) = $self->glacier->Get_job_output($job->vault, $job->id); if ($self->glacier->lasterr) { $self->abend(EX_FAILURE, "downoad failed: ", @@ -253,14 +254,14 @@ sub _download_multipart { } # Number of parts to download: my $total_parts = int(($archive_size + $part_size - 1) / $part_size); # Compute the number of parts per job my $job_parts = int(($total_parts + $njobs - 1) / $njobs); - $self->debug(1, - "downloading", $job->file_name(1), "to $localname in chunks of $part_size bytes, in $njobs jobs, with $job_parts parts per job"); + $self->debug(1, "$job: downloading in chunks of $part_size bytes, in $njobs jobs, with $job_parts parts per job"); + return if $self->dry_run; use Fcntl qw(SEEK_SET); my $fd = $self->_open_output($localname); my @part_hashes :shared = (); |