*** perlindex.ref2 Sun Oct 19 15:50:57 2008
--- perlindex.PL Sun Oct 19 16:23:04 2008
***************
*** 4,12 ****
# -*- Mode: Perl -*-
# Author : Ulrich Pfeifer
# Created On : Mon Jan 22 13:00:41 1996
! # Last Modified On: Sun Oct 19 16:26:42 2008
# Language : Perl
! # Update Count : 370
# Status : Unknown, Use with caution!
#
# (C) Copyright 1996-2005, Ulrich Pfeifer, all rights reserved.
--- 4,12 ----
# -*- Mode: Perl -*-
# Author : Ulrich Pfeifer
# Created On : Mon Jan 22 13:00:41 1996
! # Last Modified On: Sun Oct 19 16:23:04 2008
# Language : Perl
! # Update Count : 387
# Status : Unknown, Use with caution!
#
# (C) Copyright 1996-2005, Ulrich Pfeifer, all rights reserved.
***************
*** 128,134 ****
for $name (@ARGV) {
my $fns = $name;
$fns =~ s:\Q$prefix/::;
! if ($SEEN{$fns}) {
my ($mtime, $did) = unpack "$p$p", $SEEN{$fns};
if ((stat $name)[9] > $mtime) {
# mark document as deleted
--- 128,134 ----
for $name (@ARGV) {
my $fns = $name;
$fns =~ s:\Q$prefix/::;
! if (exists $SEEN{$fns}) {
my ($mtime, $did) = unpack "$p$p", $SEEN{$fns};
if ((stat $name)[9] > $mtime) {
# mark document as deleted
***************
*** 149,155 ****
--- 149,170 ----
}
}
}
+ # Check if all (previuosly) indexed files are still available
+ # This may take some time.
+ warn "Validating index ...\n";
+ while (my ($fns, $value) = each %SEEN) {
+ my $path = $fns; $path = $prefix.'/'.$path unless $path =~ m:^/:;
+ unless (-f $path) {
+ my ($mtime, $did) = unpack "$p$p", $value;
+ # mark document as deleted
+ warn "Marking $did ($fns) as deleted\n";
+ delete $FN{$did};
+ delete $SEEN{$fns};
+ $gc_required++;
+ }
+ }
if ($gc_required) {
+ warn "Garbadge collecting ...\n";
# garbadge collection, this is awfully slow
while (my ($word,$list) = each %IF) {
my %post = unpack($p.'*',$list);
***************
*** 200,211 ****
$prune = 1;
}
$fns =~ s:\Q$prefix/::;
! return if $SEEN{$fns};
return unless -f $_;
if ($name =~ /man|bin|\.(pod|pm|txt)$/) {
if (!/(~|,v)$/) {
$did = $FN{'last'}++;
! $SEEN{$fns} = &index($name, $fns, $did);
}
}
}
--- 215,242 ----
$prune = 1;
}
$fns =~ s:\Q$prefix/::;
!
! if (exists $SEEN{$fns}) {
! my ($mtime, $did) = unpack "$p$p", $SEEN{$fns};
! if ((stat $name)[9] > $mtime) {
! # mark document as deleted
! delete $FN{$did};
! warn "Marking $did,$mtime ($name) as deleted\n";
! $gc_required++;
! } else {
! # index up to date
! return;
! }
! }
!
return unless -f $_;
if ($name =~ /man|bin|\.(pod|pm|txt)$/) {
if (!/(~|,v)$/) {
$did = $FN{'last'}++;
! if (&index($name, $fns, $did)) {
! my ($mtime) = (stat $name)[9];
! $SEEN{$fns} = pack "$p$p", (stat $name)[9], $did;
! }
}
}
}