%pagesources=%pagemtime=%oldlinks=%links=%depends=
%destsources=%renderedfiles=%pagecase=%pagestate=();
}
- open (my $in, "<", "$config{wikistatedir}/index") || return;
+ my $in;
+ if (! open ($in, "<", "$config{wikistatedir}/indexdb")) {
+ if (-e "$config{wikistatedir}/index") {
+ system("ikiwiki-transition", "indexdb", $config{srcdir});
+ open ($in, "<", "$config{wikistatedir}/indexdb") || return;
+ }
+ else {
+ return;
+ }
+ }
my $ret=Storable::fd_retrieve($in);
if (! defined $ret) {
return 0;
}
my %index=%$ret;
- foreach my $page (keys %index) {
- my %d=%{$index{$page}};
+ foreach my $src (keys %index) {
+ my %d=%{$index{$src}};
+ my $page=pagename($src);
$pagectime{$page}=$d{ctime};
if (! $config{rebuild}) {
+ $pagesources{$page}=$src;
$pagemtime{$page}=$d{mtime};
- $pagesources{$page}=$d{src};
$renderedfiles{$page}=$d{dest};
if (exists $d{links} && ref $d{links}) {
$links{$page}=$d{links};
if (! -d $config{wikistatedir}) {
mkdir($config{wikistatedir});
}
- my $newfile="$config{wikistatedir}/index.new";
+ my $newfile="$config{wikistatedir}/indexdb.new";
my $cleanup = sub { unlink($newfile) };
open (my $out, '>', $newfile) || error("cannot write to $newfile: $!", $cleanup);
my %index;
foreach my $page (keys %pagemtime) {
next unless $pagemtime{$page};
+ my $src=$pagesources{$page};
- $index{$page}={
+ $index{$src}={
ctime => $pagectime{$page},
mtime => $pagemtime{$page},
- src => $pagesources{$page},
dest => $renderedfiles{$page},
links => $links{$page},
};
if (exists $depends{$page}) {
- $index{$page}{depends} = $depends{$page};
+ $index{$src}{depends} = $depends{$page};
}
if (exists $pagestate{$page}) {
foreach my $id (@hookids) {
foreach my $key (keys %{$pagestate{$page}{$id}}) {
- $index{$page}{state}{$id}{$key}=$pagestate{$page}{$id}{$key};
+ $index{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key};
}
}
}
my $ret=Storable::nstore_fd(\%index, $out);
return if ! defined $ret || ! $ret;
close $out || error("failed saving to $newfile: $!", $cleanup);
- rename($newfile, "$config{wikistatedir}/index") ||
- error("failed renaming $newfile to $config{wikistatedir}/index", $cleanup);
+ rename($newfile, "$config{wikistatedir}/indexdb") ||
+ error("failed renaming $newfile to $config{wikistatedir}/indexdb", $cleanup);
return 1;
} #}}}