[perl-HTTP-Tiny] Croak on failed write into a file

Petr Pisar ppisar at fedoraproject.org
Wed Nov 27 11:33:10 UTC 2013


commit 2dacff0c7d0ec4b40aad0f4c47ce6be7195e749a
Author: Petr Písař <ppisar at redhat.com>
Date:   Wed Nov 27 12:21:34 2013 +0100

    Croak on failed write into a file

 ...y-0.038-Croak-on-failed-write-into-a-file.patch |   36 ++++++++++++++++++++
 perl-HTTP-Tiny.spec                                |    9 ++++-
 2 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/HTTP-Tiny-0.038-Croak-on-failed-write-into-a-file.patch b/HTTP-Tiny-0.038-Croak-on-failed-write-into-a-file.patch
new file mode 100644
index 0000000..3c7d069
--- /dev/null
+++ b/HTTP-Tiny-0.038-Croak-on-failed-write-into-a-file.patch
@@ -0,0 +1,36 @@
+From 4ead7785b495b48f027f77abe2b1173f3c05f02c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
+Date: Wed, 27 Nov 2013 10:45:39 +0100
+Subject: [PATCH 1/2] Croak on failed write into a file
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The mirror() method saves a document into a file. Any error while
+writing to the file, e.g. no disk space, was ignored. This patch fixes
+it by croaking on such I/O error.
+
+Signed-off-by: Petr Písař <ppisar at redhat.com>
+---
+ lib/HTTP/Tiny.pm | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/lib/HTTP/Tiny.pm b/lib/HTTP/Tiny.pm
+index 0178d65..48763ff 100644
+--- a/lib/HTTP/Tiny.pm
++++ b/lib/HTTP/Tiny.pm
+@@ -116,7 +116,10 @@ sub mirror {
+     open my $fh, ">", $tempfile
+         or Carp::croak(qq/Error: Could not open temporary file $tempfile for downloading: $!\n/);
+     binmode $fh;
+-    $args->{data_callback} = sub { print {$fh} $_[0] };
++    $args->{data_callback} = sub {
++        print {$fh} $_[0]
++        or Carp::croak(qq/Error: Could not write into temporary file $tempfile: $!\n/);
++    };
+     my $response = $self->request('GET', $url, $args);
+     close $fh
+         or Carp::croak(qq/Error: Could not close temporary file $tempfile: $!\n/);
+-- 
+1.8.3.1
+
diff --git a/perl-HTTP-Tiny.spec b/perl-HTTP-Tiny.spec
index dc7868f..4418f00 100644
--- a/perl-HTTP-Tiny.spec
+++ b/perl-HTTP-Tiny.spec
@@ -1,11 +1,14 @@
 Name:           perl-HTTP-Tiny
 Version:        0.038
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        Small, simple, correct HTTP/1.1 client
 License:        GPL+ or Artistic
 Group:          Development/Libraries
 URL:            http://search.cpan.org/dist/HTTP-Tiny/
 Source0:        http://www.cpan.org/authors/id/D/DA/DAGOLDEN/HTTP-Tiny-%{version}.tar.gz
+# Check for write failure, bug #1031096,
+# <https://github.com/chansen/p5-http-tiny/issues/32>
+Patch0:         HTTP-Tiny-0.038-Croak-on-failed-write-into-a-file.patch
 BuildArch:      noarch
 BuildRequires:  perl
 BuildRequires:  perl(ExtUtils::MakeMaker) >= 6.17
@@ -51,6 +54,7 @@ resumes after EINTR.
 
 %prep
 %setup -q -n HTTP-Tiny-%{version}
+%patch0 -p1
 
 %build
 perl Makefile.PL INSTALLDIRS=vendor
@@ -70,6 +74,9 @@ make test
 %{_mandir}/man3/*
 
 %changelog
+* Wed Nov 27 2013 Petr Pisar <ppisar at redhat.com> - 0.038-2
+- Croak on failed write into a file (bug #1031096)
+
 * Tue Nov 19 2013 Petr Pisar <ppisar at redhat.com> - 0.038-1
 - 0.038 bump
 


More information about the scm-commits mailing list