App-lcpan

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


	- [ux] Avoid creating index database automatically when we are just
	  reading the index (ro mode).

	- Allow customizing db filename via --index-name.


0.11    2015-02-24  Released-By: PERLANCAR

        - To help chase bugs in updating index, now keeps old indexes (by
          default 7, customize via --num-backups).


0.10    2015-02-06  Released-By: PERLANCAR

	- Mark common args with 'common' tag.

	- Add convenient option --all (equivalent to: --phase ALL --rel
	  ALL).


lib/App/lcpan.pm  view on Meta::CPAN

    summary => 'Manage local CPAN mirror',
};

sub _set_args_default {
    my $args = shift;
    if (!$args->{cpan}) {
        require File::HomeDir;
        $args->{cpan} = File::HomeDir->my_home . '/cpan';
    }
    $args->{index_name} //= 'index.db';
    if (!defined($args->{num_backups})) {
        $args->{num_backups} = 7;
    }
    $args->{use_bootstrap} //= 1;
    $args->{update_db_schema} //= 1;
}

# set {added_,updated_,added_or_udpated_}since from
# {added_,updated_,added_or_updated_}since_last_{index_update,n_index_updates},
# set, since SQL query will usually use the former
sub _set_since {
    my ($args, $dbh) = @_;

lib/App/lcpan.pm  view on Meta::CPAN

    require DBI;
    require File::Temp;
    require IO::Compress::Gzip;

    my %args = @_;
    _set_args_default(\%args);
    my $cpan = $args{cpan};
    my $index_name = $args{index_name};

    my $db_path = _db_path($cpan, $index_name);
    if ($args{num_backups} > 0 && (-f $db_path)) {
        require File::Copy;
        require Logfile::Rotate;
        log_info("Rotating old indexes ...");
        my $rotate = Logfile::Rotate->new(
            File  => $db_path,
            Count => $args{num_backups},
            Gzip  => 'no',
        );
        $rotate->rotate;
        File::Copy::copy("$db_path.1", $db_path)
              or return [500, "Copy $db_path.1 -> $db_path failed: $!"];
    }

    my $dbh  = _connect_db('rw', $cpan, $index_name, $args{use_bootstrap}, $args{update_db_schema});

    # check whether we need to reindex if a sufficiently old (and possibly



( run in 0.606 second using v1.01-cache-2.11-cpan-49f99fa48dc )