diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2022-04-15 10:54:01 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2022-04-15 10:54:01 +0000 |
commit | 11b07ee925f9cc04ce62f08c929945bbce0f0368 (patch) | |
tree | 69b7e6a7cf4b72ef4b795f5b4b283b7338b0dbac /usr.sbin | |
parent | ea0d59541320b4a85c8fd39b873ded03cf380b95 (diff) |
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.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageLocation.pm | 18 |
1 files 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 <espie@openbsd.org> # @@ -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 = ''; |