CPAN-Mini-Inject-Server

 view release on metacpan or  search on metacpan

lib/CPAN/Mini/Inject/Server.pm  view on Meta::CPAN

    my $module_author = $query->param('authorid');
    my $module_version = $query->param('version');

    my $module_filename = $query->param('file');

    if (not $module_filename)
    {
        $self->header_add(-status => '400 No module archive supplied'); 
        return;
    }

    # check filename ends with tar.gz

    my $bytesread;
    my $tmp_fh;

    # -e tmp file here to check we don't bash on it can be racey, just forget
    # about it

    my $tmp_module_filename = $module_name;
    $tmp_module_filename =~ s/::/-/g;
    $tmp_module_filename = "/tmp/$tmp_module_filename-$module_version.tar.gz";

    if (not open ($tmp_fh, '>', $tmp_module_filename))
    {
        $self->header_add(-status => '500 Internal System Error');
        return;
    }

    while ($bytesread = read($module_filename, my $buffer, 1024))
    {
        print $tmp_fh $buffer;
    }

    close ($tmp_fh);


    my $mcpi = $self->_mcpi();
    $mcpi->add(
        module => $module_name,
        authorid => $module_author,
        version => $module_version,
        file => $tmp_module_filename,
    );

    unlink $tmp_module_filename;

    $mcpi->writelist();

    $self->header_add(-status => '202 Module added');
    return;
} # end of subroutine add


=head2 update

Updates the cpan mirror

=cut

sub update :Runmode {
    my $self = shift;

    my $mcpi = $self->_mcpi();

    $mcpi->update_mirror();
    $mcpi->inject();

    $self->header_add(-status => '202 Mirror updated');
    return;
} # end of subroutine update


=head2 inject

Injects all added modules into the cpan mirror

=cut

sub inject :Runmode {
    my $self = shift;

    my $mcpi = $self->_mcpi();

    $mcpi->inject();

    $self->header_add(-status => '202 Modules injected');
    return;
} # end of subroutine inject


=head1 AUTHOR

Christopher Mckay, C<< <potatohead at potatolan.com> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-cpan-mini-inject-server at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPAN-Mini-Inject-Server>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.

=head1 TO DO

Need to add logging down to trace levels to this

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc CPAN::Mini::Inject::Server


You can also look for information at:

=over 4

=item * RT: CPAN's request tracker

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPAN-Mini-Inject-Server>

=item * AnnoCPAN: Annotated CPAN documentation



( run in 2.610 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )