Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkgstat: downloads require R2 presigned URLs #216

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lib/OOCEapps/Model/PkgStat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@ $updateGeoIP = sub {
my $self = shift;
my $oneoff = shift;

my $res = $self->ua->get($self->config->{geoip_url})->result;
die "ERROR: downloading GeoIP database from '$self->config->{geoip_url}'\n"
if !$res->is_success;

my $fh = File::Temp->new(SUFFIX => 'tar.gz');
close $fh;
my $filename = $fh->filename;
$res->content->asset->move_to($filename);

# downloads require R2 presigned URLs which Mojo::UserAgent does not support
# use curl as a workaround
my $url = $self->config->{geoip_url};
system (qw(/usr/bin/curl -Ls -o), $filename, $url)
and die "ERROR: executing curl: $!\n";

# sanity check for size
(stat $filename)[7] > 1_000_000
or die "ERROR: downloading GeoIP database from '$url'\n";

my $tar = Archive::Tar->new;
$tar->read($filename);
Expand Down Expand Up @@ -213,7 +218,7 @@ __END__

=head1 COPYRIGHT

Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
Copyright 2024 OmniOS Community Edition (OmniOSce) Association.

=head1 LICENSE

Expand Down
Loading