Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement panda --cpan update
This will download the list of packages/binaries/etc. We also download these when 24hours-ish
have passed for commands like: --cpan install, --cpan search, etc.
  • Loading branch information
FROGGS committed Sep 30, 2014
1 parent 683e0c0 commit bd34c5d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 0 additions & 2 deletions TODO
Expand Up @@ -23,8 +23,6 @@ Resources on CPAN:
Inline v1
^-- display description

* let panda --cpan update fetch p6dists.json.gz, p6provides.json.gz and p6binaries.json.gz

* Resources on CPAN:
Inline v1.2
Inline v1
Expand Down
8 changes: 5 additions & 3 deletions bin/panda
Expand Up @@ -47,7 +47,7 @@ multi MAIN ('install', *@modules, Bool :$notests, Bool :$nodeps, Bool :$cpan, Bo
try {
$panda.resolve($x, :$notests, :$nodeps, :$cpan, :$github);
CATCH {
default { say X::Panda }
default { say $_.message }
#~ when X::Panda { say $_.message }
}
};
Expand All @@ -60,8 +60,10 @@ multi MAIN ('list', Bool :$installed, Bool :$verbose) {
}

#= Update the module database
multi MAIN ('update') {
$panda.ecosystem.update;
multi MAIN ('update', Bool :$cpan, Bool :$github is copy) {
$github = True unless $cpan;
$panda.ecosystem.update if $github;
$panda.cpan.update($panda, :force) if $cpan;
}

#= Display information about specified modules
Expand Down
2 changes: 1 addition & 1 deletion lib/Panda.pm
Expand Up @@ -152,7 +152,7 @@ class Panda {
}
my $bone = $.ecosystem.get-project($proj) if $github;
if $cpan {
$.cpan.fetch-if-needed(self);
$.cpan.update(self);
$bone ||= $.cpan.get-project($proj);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Panda/App.pm
Expand Up @@ -81,7 +81,7 @@ sub wrap ($str) is export {
}

sub search-projects($panda, $string, :$cpan, :$github) is export {
$panda.cpan.fetch-if-needed($panda) if $cpan;
$panda.cpan.update($panda) if $cpan;
if $github {
say "Resources on github:";
for $panda.ecosystem.project-list -> $project {
Expand Down
5 changes: 3 additions & 2 deletions lib/Panda/CPAN.pm
Expand Up @@ -5,11 +5,12 @@ class Panda::CPAN {
use Panda::Project;
use Compress::Zlib;

method fetch-if-needed($panda) {
method update($panda, :$force) {
for < p6dists.json p6dists.json.gz
p6provides.json p6provides.json.gz
p6binaries.json p6binaries.json.gz > -> $json, $gz {
unless "$!pandadir/$gz".IO.s { # }
my $io = "$!pandadir/$gz".IO;
if $force || !$io.s || 0 < $io.modified < now - 86400 {
my $i = 0;
for $panda.mirrors.urls($panda) -> $url {
$i ?? $panda.announce("Retrying $url/authors/$gz")
Expand Down
7 changes: 4 additions & 3 deletions lib/Panda/Mirrors.pm
Expand Up @@ -5,15 +5,16 @@ class Panda::Mirrors {

#~ use JSON::Tiny;

method fetch-if-needed($panda) {
unless $!mirrorsfile.IO.e {
method update($panda, :$force) {
my $io = $!mirrorsfile.IO;
if $force || !$io.s || 0 < $io.modified < now - 86400 {
$panda.announce("Fetching $!url");
$panda.fetcher.fetch: $!url, $!mirrorsfile;
}
}

method probe($panda, $limit = Inf) {
self.fetch-if-needed($panda);
self.update($panda);

my grammar Ping {
rule TOP {
Expand Down

0 comments on commit bd34c5d

Please sign in to comment.