From 9d47f02deb1678a80669616ca5666b0e3fbf1c17 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Thu, 3 Nov 2005 13:28:08 +0000 Subject: kludge: avoid creating non-empty files. I don't like the fix, but it works... --- usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'usr.sbin/pkg_add') diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index 58fe47361bc..337838a28e7 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocator.pm,v 1.47 2005/11/02 22:26:51 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.48 2005/11/03 13:28:07 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie # @@ -364,6 +364,7 @@ sub pkg_copy kill $sig, $$; }; + my $nonempty = 0; { local $SIG{'PIPE'} = $handler; @@ -380,13 +381,20 @@ sub pkg_copy if (!defined $n) { die "Error reading\n"; } + if ($n > 0) { + $nonempty = 1; + } syswrite $copy, $buffer; syswrite STDOUT, $buffer; } while ($n != 0); close($copy); } - rename $filename, "$dir/$name"; + if ($nonempty) { + rename $filename, "$dir/$name"; + } else { + unlink $filename; + } } sub open_pipe -- cgit v1.2.3