NAME

App::DistSync - Utility for synchronizing distribution mirrors

SYNOPSIS

use App::DistSync;

my $ds = App::DistSync->new(
        dir => "/var/www/www.example.com/dist",
        pid => $$,
        timeout => 60,
        proxy => 'http://http.example.com:8001/',
    );

$ds->init or die "Initialization error";

$ds->sync or die "Sync error";

DESCRIPTION

Utility for synchronizing distribution mirrors

METHODS

This module implements the following methods

new

my $ds = new App::DistSync(
        dir => "/var/www/www.example.com/dist",
        pid => $$,
        timeout => 60,
        proxy => 'http://http.example.com:8001/',
    );

Returns the object

dir

my $abs_dir = $ds->dir;

Returns absolute pathname of working directory

fetch

my $struct = $self->fetch( $URI_STRING, "path/to/file.txt", "/tmp/file.txt" );

Fetching file from remote resource by URI and filename. The result will be written to the specified file. For example: "/tmp/file.txt"

Returns structure, contains:

{
    status  => 1,         # Status. 0 - Errors; 1 - OK
    mtime   => 123456789, # Last-Modified in ctime format or 0 in case of errors
    size    => 123,       # Content-length
    code    => 200,       # HTTP Status code
};

init

$ds->init or die ("Initialization error");

Initializing the mirror in the specified directory

mkmani

$ds->mkmani;

Generation the new MANIFEST file

pid

my $pid = $ds->pid;

Returns the pid of current process

status

$ds->status;

Show statistic information

sync

$ds->sync or die ("Sync error");

Synchronization of the specified directory with the remote resources (mirrors)

ua

my $ua = $ds->ua;

Returns the UserAgent instance (LWP::UserAgent)

verbose

warn "Error details\n" if $ds->verbose;

This method returns verbose flag

HISTORY

See Changes file

TO DO

See TODO file

SEE ALSO

LWP::Simple

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2025 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/