From 054e417d8819d0d22e54b30df983085944ca6e4a Mon Sep 17 00:00:00 2001 From: espie Date: Fri, 15 Apr 2022 10:54:00 +0000 Subject: [PATCH] make use of the fact that repositories are unique objects: we don't need string comparison, we can simply annotate the quirks repository as cached. this does streamline the code somewhat so simply activate warp-speed by uncommenting one line. --- usr.sbin/pkg_add/OpenBSD/PackageLocation.pm | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm index b527382f3c4..1a7a2d902d8 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.54 2022/04/13 21:22:40 espie Exp $ +# $OpenBSD: PackageLocation.pm,v 1.55 2022/04/15 10:54:00 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -60,10 +60,10 @@ OpenBSD::Auto::cache(update_info, if ($self->name =~ /^quirks\-/) { return $self->plist; } -# if (-f OpenBSD::Paths->updateinfodb) { -# my $info = $self->get_update_info_fromdb; -# return $info if defined $info; -# } + if ($self->{repository}{is_cached}) { + my $info = $self->get_update_info_fromdb; + return $info if defined $info; + } return $self->plist(\&OpenBSD::PackingList::UpdateInfoOnly, sub { return 0 if $_[0] =~ m/^\@option\s+always-update\b/m; @@ -72,21 +72,17 @@ OpenBSD::Auto::cache(update_info, }); }); -my $db_location = ""; - sub set_db_location { my ($class, $location) = @_; - $db_location = $location->{repository}->url; + # XXX UNCOMMENT THE NEXT LINE TO TURN ON CACHING +# $location->{repository}{is_cached} = 1; } sub get_update_info_fromdb { my $self = shift; - if ($self->{repository}->url ne $db_location) { - return; - } open my $fh, "-|", OpenBSD::Paths->locate, '-d', OpenBSD::Paths->updateinfodb, $self->name.":*"; my $content = ''; -- 2.20.1