summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2006-03-07 17:25:48 +0000
committerMarc Espie <espie@cvs.openbsd.org>2006-03-07 17:25:48 +0000
commitf4c3f75388450373c6e5f4b06320e0681d39fa54 (patch)
tree5f3598f21ef9a41525414906e0ea2e8cb56984ce
parentb0ad9c70bcf9e3442727eea3f5ebae6b76518db1 (diff)
do not write partial files out if the PKG_CACHE filesystem overflows.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository.pm12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
index 5dd3f6967be..c04ab7b5d57 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageRepository.pm,v 1.8 2006/03/07 15:00:15 bernd Exp $
+# $OpenBSD: PackageRepository.pm,v 1.9 2006/03/07 17:25:47 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -371,6 +371,7 @@ sub pkg_copy
};
my $nonempty = 0;
+ my $error = 0;
{
local $SIG{'PIPE'} = $handler;
@@ -390,13 +391,18 @@ sub pkg_copy
if ($n > 0) {
$nonempty = 1;
}
- syswrite $copy, $buffer;
+ if (!$error) {
+ my $r = syswrite $copy, $buffer;
+ if (!defined $r || $r < $n) {
+ $error = 1;
+ }
+ }
syswrite STDOUT, $buffer;
} while ($n != 0);
close($copy);
}
- if ($nonempty) {
+ if ($nonempty && !$error) {
rename $filename, "$dir/$name";
} else {
unlink $filename;