|
|
6f6bbd |
From 4ead7785b495b48f027f77abe2b1173f3c05f02c Mon Sep 17 00:00:00 2001
|
|
|
6f6bbd |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
6f6bbd |
Date: Wed, 27 Nov 2013 10:45:39 +0100
|
|
|
6f6bbd |
Subject: [PATCH 1/2] Croak on failed write into a file
|
|
|
6f6bbd |
MIME-Version: 1.0
|
|
|
6f6bbd |
Content-Type: text/plain; charset=UTF-8
|
|
|
6f6bbd |
Content-Transfer-Encoding: 8bit
|
|
|
6f6bbd |
|
|
|
6f6bbd |
The mirror() method saves a document into a file. Any error while
|
|
|
6f6bbd |
writing to the file, e.g. no disk space, was ignored. This patch fixes
|
|
|
6f6bbd |
it by croaking on such I/O error.
|
|
|
6f6bbd |
|
|
|
6f6bbd |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
6f6bbd |
---
|
|
|
6f6bbd |
lib/HTTP/Tiny.pm | 5 ++++-
|
|
|
6f6bbd |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
6f6bbd |
|
|
|
6f6bbd |
diff --git a/lib/HTTP/Tiny.pm b/lib/HTTP/Tiny.pm
|
|
|
6f6bbd |
index 0178d65..48763ff 100644
|
|
|
6f6bbd |
--- a/lib/HTTP/Tiny.pm
|
|
|
6f6bbd |
+++ b/lib/HTTP/Tiny.pm
|
|
|
6f6bbd |
@@ -116,7 +116,10 @@ sub mirror {
|
|
|
6f6bbd |
open my $fh, ">", $tempfile
|
|
|
6f6bbd |
or Carp::croak(qq/Error: Could not open temporary file $tempfile for downloading: $!\n/);
|
|
|
6f6bbd |
binmode $fh;
|
|
|
6f6bbd |
- $args->{data_callback} = sub { print {$fh} $_[0] };
|
|
|
6f6bbd |
+ $args->{data_callback} = sub {
|
|
|
6f6bbd |
+ print {$fh} $_[0]
|
|
|
6f6bbd |
+ or Carp::croak(qq/Error: Could not write into temporary file $tempfile: $!\n/);
|
|
|
6f6bbd |
+ };
|
|
|
6f6bbd |
my $response = $self->request('GET', $url, $args);
|
|
|
6f6bbd |
close $fh
|
|
|
6f6bbd |
or Carp::croak(qq/Error: Could not close temporary file $tempfile: $!\n/);
|
|
|
6f6bbd |
--
|
|
|
6f6bbd |
1.8.3.1
|
|
|
6f6bbd |
|