Apache-Wyrd
view release on metacpan or search on metacpan
Wyrd/Site/Index.pm view on Meta::CPAN
from an index. Please use the more fault-tolerant
Apache::Wyrd::Site::IndexBot object.
It takes the Apache req object as an argument, and returns a scalar of the
text of the output from that purge.
=cut
sub purge_missing {
my ($self, $req) = @_;
die ("index site requires an Apache request object, not a: " . ref($req)) unless (ref($req) eq 'Apache');
my $root = $req->document_root;
my $result = "<P>First checking for deleted documents:";
my $index = $self->write_db;
my $cursor = $index->db_cursor;
my %exists = ();
$cursor->c_get(my $id, my $document, DB_FIRST);
do {
$exists{$id}=1 if ($id =~ /^\d\d/);
} until ($cursor->c_get($id, $document, DB_NEXT));
$cursor->c_get($id, $document, DB_FIRST);
do {
my ($current_id) = $id =~ /^[\x00-\xff]%(\d+)/;
if ($id =~ /^\d\d/) {
if (-f "$root$document") {
$result .= "<BR>keeping $root$document"
} else {
$result .= "<BR>destroying $root$document: " . $self->purge_entry($id);
}
} elsif (not($exists{$current_id})) {
my $error = $index->db_del($id);
$result .= "<br>warning: purged corrupt data for nonexistent id $current_id: ". ($error ? 'failed!' : 'succeeded.');
}
} until ($cursor->c_get($id, $document, DB_NEXT));
$cursor->c_close;
$self->close_db;
return "$result</p>";
}
=pod
=item (scalar) C<skip_file> (scalar)
Simple filter for removing files from consideration by the index. Intended
as an over-loadable handle. Returns 0 if the file should be indexed.
Defaults to 0.
=cut
sub skip_file {
my ($self, $file) = @_;
return 0;
}
=pod
=item (objectref) C<ua> (hashref)
Another over-loadable handle. Should return a handle to a LWP useragent
object (See LWP::UserAgent) appropriate for navigating the site, which is to
say it should have some way of handling access and authentication
appropriate to the site's construction. There is no default ua; the
webmaster will need to define it in order to use this object.
Note that this method is required by Apache::Wyrd::Services::IndexBot.
=cut
sub ua {
my ($self) = @_;
$self->_raise_exception('You need to privide a ua method appropriate to your web site.');
}
=pod
=back
=head1 BUGS/CAVEATS
An obsolete appendix to an obsolete mechanism. Reserves the new method,
which it passes unaltered to Apache::Wyrd::Services::Index. index_site,
skip_file, and purge_missing are obsolete and may be dropped in future
versions. See Apache::Wyrd::Services::Index for other bugs/warnings.
=cut
sub new {
return &Apache::Wyrd::Services::Index::new(@_);
}
=pod
=head1 AUTHOR
Barry King E<lt>wyrd@nospam.wyrdwright.comE<gt>
=head1 SEE ALSO
=over
=item Apache::Wyrd
General-purpose HTML-embeddable perl object
=item Apache::Wyrd::Services::Index
General-purpose search engine index object
=back
=head1 LICENSE
Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.
See LICENSE under the documentation for C<Apache::Wyrd>.
=cut
1;
( run in 1.123 second using v1.01-cache-2.11-cpan-e1769b4cff6 )