23 Nov 2021 19:30:10 UTC
- Distribution: CPANPLUS
- Module version: 0.9914
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (3)
- Testers (664 / 4 / 0)
- KwaliteeBus factor: 1
- 71.49% Coverage
- License: perl_5
- Activity24 month
- Download (607.36KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- $path = _fetch( module => $modobj, [fetchdir => '/path/to/save/to', fetch_from => 'scheme://path/to/fetch/from', verbose => BOOL, force => BOOL, prefer_bin => BOOL, ttl => $seconds] )
CPANPLUS::Internals::Fetch - internals for fetching files
my $output = $cb->_fetch( module => $modobj, fetchdir => '/path/to/save/to', verbose => BOOL, force => BOOL, ); $cb->_add_fail_host( host => 'foo.com' ); $cb->_host_ok( host => 'foo.com' );
CPANPLUS::Internals::Fetch fetches files from either ftp, http, file or rsync mirrors.
This is the rough flow:
$cb->_fetch Delegate to File::Fetch;
$path = _fetch( module => $modobj, [fetchdir => '/path/to/save/to', fetch_from => 'scheme://path/to/fetch/from', verbose => BOOL, force => BOOL, prefer_bin => BOOL, ttl => $seconds] )
_fetchwill fetch files based on the information in a module object. You always need a module object. If you want a fake module object for a one-off fetch, look at
fetchdiris the place to save the file to. Usually this information comes from your configuration, but you can override it expressly if needed.
fetch_fromlets you specify an URI to get this file from. If you do not specify one, your list of configured hosts will be probed to download the file from.
forceforces a new download, even if the file already exists.
verbosesimply indicates whether or not to print extra messages.
prefer_binindicates whether you prefer the use of commandline programs over perl modules. Defaults to your corresponding config setting.
ttl(in seconds) indicates how long a cached copy is valid for. If the fetch time of the local copy is within the ttl, the cached copy is returned. Otherwise, the file is refetched.
_fetchfigures out, based on the host list, what scheme to use and from there, delegates to
File::Fetchdo the actual fetching.
Returns the path of the output file on success, false on failure.
Note that you can set a
blackliston certain methods in the config. Simply add the identifying name of the method (ie,
lwp) to: $conf->_set_fetch( blacklist => ['lwp'] );
LWPfunction will be skipped by
Mark a particular host as bad. This makes
CPANPLUS::Internals::Fetchskip it in fetches until this cache is flushed.
Query the cache to see if this host is ok, or if it has been flagged as bad.
Returns true if the host is ok, false otherwise.