From f526a68ca0a0fffc4bfee5555fb1a3190bf3cb7d Mon Sep 17 00:00:00 2001 From: espie Date: Sun, 8 May 2022 13:31:40 +0000 Subject: [PATCH] get rid of horribly complex optimization that's no longer relevant. For update-info, we used to try to stop reading the CONTENTS file from the stream as soon as we had enough, but - most update-info will be cached - the ones that won't are @option always-update, so they need the full plist anyway - most packages are signed, so we need a full 64KB of data to check the hash. --- usr.sbin/pkg_add/OpenBSD/PackageLocation.pm | 26 ++++++--------------- usr.sbin/pkg_add/OpenBSD/Ustar.pm | 8 ++----- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm index cb795f9649a..63a6cd11baa 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocation.pm,v 1.59 2022/05/08 13:21:04 espie Exp $ +# $OpenBSD: PackageLocation.pm,v 1.60 2022/05/08 13:31:40 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -73,12 +73,7 @@ OpenBSD::Auto::cache(update_info, !defined $state->defines("CACHING_RECHECK")) { return $info; } - my $result = $self->plist(\&OpenBSD::PackingList::UpdateInfoOnly, - sub { - return 0 if $_[0] =~ m/^\@option\s+always-update\b/m; - return 1 if $_[0] =~ m/^\@(?:newgroup|newuser|cwd)\b/m; - return 0; - }); + my $result = $self->plist(\&OpenBSD::PackingList::UpdateInfoOnly); if (defined $info) { my $s1 = OpenBSD::Signature->from_plist($info); my $s2 = OpenBSD::Signature->from_plist($result); @@ -137,12 +132,12 @@ sub _set_callback sub find_contents { - my ($self, $extra) = @_; + my $self = shift; while (my $e = $self->next) { if ($e->isFile && is_info_name($e->{name})) { if ($e->{name} eq CONTENTS ) { - my $v = $e->contents($extra); + my $v = $e->contents; return $v; } } else { @@ -154,18 +149,11 @@ sub find_contents sub contents { - my ($self, $extra) = @_; + my $self = shift; if (!defined $self->{contents}) { if (!$self->_opened) { return; } - if (defined $extra) { - my $contents = $self->find_contents($extra); - if ($contents) { - $self->unput; - } - return $contents; - } $self->{contents} = $self->find_contents; } @@ -257,7 +245,7 @@ sub info sub plist { - my ($self, $code, $extra) = @_; + my ($self, $code) = @_; require OpenBSD::PackingList; if (defined $self->{dir} && -f $self->{dir}.CONTENTS) { @@ -267,7 +255,7 @@ sub plist $plist->set_infodir($self->{dir}); return $plist; } - if (my $value = $self->contents($extra)) { + if (my $value = $self->contents) { return OpenBSD::PackingList->fromfile(\$value, $code); } # hopeless diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index aef9740d87d..8fb2e3e3155 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Ustar.pm,v 1.89 2021/08/09 16:40:20 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.90 2022/05/08 13:31:41 espie Exp $ # # Copyright (c) 2002-2014 Marc Espie # @@ -862,7 +862,7 @@ sub extract_to_fh sub contents { - my ($self, $lookfor) = @_; + my $self = shift; my $toread = $self->{size}; my $buffer; my $offset = 0; @@ -874,10 +874,6 @@ sub contents while ($toread != 0) { my $sz = $toread; - if (defined $lookfor) { - last if (defined $buffer) and &$lookfor($buffer); - $sz = 1024 if $sz > 1024; - } my $actual = read($self->{archive}{fh}, $buffer, $sz, $offset); if (!defined $actual) { $self->fatal("Error reading from archive: #1", $!); -- 2.20.1