Apache-PAR

 view release on metacpan or  search on metacpan

PAR.pm  view on Meta::CPAN

use Archive::Zip qw( AZ_OK );
Archive::Zip::setErrorHandler(sub {});

my @pardir      = Apache->server->dir_config->get('PARDir');
my @parfiles    = Apache->server->dir_config->get('PARFile');
my @parloc      = Apache->server->dir_config->get('PARInclude');

sub handler {
	my $r = shift;
	foreach (keys(%MTIME_LIST)) {
		my $mtime = (stat($_))[9];
		if($mtime > $MTIME_LIST{$_}) {
			PAR::reload_libs($_);
			if($UNPACK_LIST{$_}) {
				unpack_par(undef, $_, Apache->server->dir_config->get('PARTempDir'))
			}
			$MTIME_LIST{$_} = $mtime;
		}
	}
	
	return 1;

PAR.pm  view on Meta::CPAN


	warn "[PAR] unpack dir is '$tmppar'\n" if DEBUG;

    # mtime check for if MD5 approach isn't used
	if (-d $tmppar) {
		if (DEBUG) {
			warn "[PAR] archive has been unpacked previously\n";
			warn "[PAR] directory age: ", -M $tmppar, "\n";
			warn "[PAR] archive age: ", -M $par, "\n";
		}
		return $tmppar if (stat($tmppar))[9] > (stat($par))[9];
		warn "[PAR] removing old unpack dir '$tmppar'" if DEBUG;
		File::Path::rmtree $tmppar;
	}
 
	# XXX Add signature check here

	# unpack the files
	foreach my $member ($zip->members) {
		# $member->fileName is always in Unix format
		# See also Archive::Zip::_asLocalName()

PAR/Static.pm  view on Meta::CPAN

	$file_path      .= $path_info;

	$file_path =~ s/^\///;


	return NOT_FOUND() unless -r $filename;

	# Use the last modified time of the PAR archive
	# Can cause cache to reload more often than necessary
	# but much faster than opening the archive every time
	my $last_modified = (stat(_))[9];

	# Initialize the cache
	my $cache_obj = _init_cache($r);
	my $contents = _get_cache($r, $filename, $file_path, $last_modified, $cache_obj);

	unless (defined $contents) {
		Archive::Zip::setErrorHandler(sub {});
		my $zip = Archive::Zip->new($filename);
		return NOT_FOUND() unless(defined($zip));



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