Reorganize index file, add a format version field.

Upgrades to the new index format should be transparent.

The version field is 3, because 1 was the old textual index, 2 was the
pre-versioned format.

This also includes some efficiency improvements to index loading, by
not copying a hash and using a reference.
master
Joey Hess 2008-09-27 16:34:09 -04:00
parent 8d04a1de61
commit 61426a7186
4 changed files with 45 additions and 25 deletions

View File

@ -1309,31 +1309,40 @@ sub loadindex () { #{{{
return;
}
}
my $ret=Storable::fd_retrieve($in);
if (! defined $ret) {
my $index=Storable::fd_retrieve($in);
if (! defined $index) {
return 0;
}
my %index=%$ret;
foreach my $src (keys %index) {
my %d=%{$index{$src}};
my $pages;
if (exists $index->{version} && ! ref $index->{version}) {
$pages=$index->{page};
}
else {
$pages=$index;
}
foreach my $src (keys %$pages) {
my $d=$pages->{$src};
my $page=pagename($src);
$pagectime{$page}=$d{ctime};
$pagectime{$page}=$d->{ctime};
if (! $config{rebuild}) {
$pagesources{$page}=$src;
$pagemtime{$page}=$d{mtime};
$renderedfiles{$page}=$d{dest};
if (exists $d{links} && ref $d{links}) {
$links{$page}=$d{links};
$oldlinks{$page}=[@{$d{links}}];
$pagemtime{$page}=$d->{mtime};
$renderedfiles{$page}=$d->{dest};
if (exists $d->{links} && ref $d->{links}) {
$links{$page}=$d->{links};
$oldlinks{$page}=[@{$d->{links}}];
}
if (exists $d{depends}) {
$depends{$page}=$d{depends};
if (exists $d->{depends}) {
$depends{$page}=$d->{depends};
}
if (exists $d{state}) {
$pagestate{$page}=$d{state};
if (exists $d->{state}) {
$pagestate{$page}=$d->{state};
}
}
$oldrenderedfiles{$page}=[@{$d{dest}}];
$oldrenderedfiles{$page}=[@{$d->{dest}}];
}
foreach my $page (keys %pagesources) {
$pagecase{lc $page}=$page;
@ -1364,7 +1373,7 @@ sub saveindex () { #{{{
next unless $pagemtime{$page};
my $src=$pagesources{$page};
$index{$src}={
$index{page}{$src}={
ctime => $pagectime{$page},
mtime => $pagemtime{$page},
dest => $renderedfiles{$page},
@ -1372,17 +1381,18 @@ sub saveindex () { #{{{
};
if (exists $depends{$page}) {
$index{$src}{depends} = $depends{$page};
$index{page}{$src}{depends} = $depends{$page};
}
if (exists $pagestate{$page}) {
foreach my $id (@hookids) {
foreach my $key (keys %{$pagestate{$page}{$id}}) {
$index{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key};
$index{page}{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key};
}
}
}
}
$index{version}="3";
my $ret=Storable::nstore_fd(\%index, $out);
return if ! defined $ret || ! $ret;
close $out || error("failed saving to $newfile: $!", $cleanup);

View File

@ -16,6 +16,8 @@ sub import { #{{{
call => \&preprocess);
hook(type => "formbuilder", id => "edittemplate",
call => \&formbuilder);
hook(type => "refresh", id => "edittemplate",
call => \&refresh);
} #}}}
sub getsetup () { #{{{
@ -138,4 +140,8 @@ sub filltemplate ($$) { #{{{
return $template->output;
} #}}}
sub refresh () {
}
1

4
debian/changelog vendored
View File

@ -19,6 +19,10 @@ ikiwiki (2.66) UNRELEASED; urgency=low
untidied content if tidy crashes. In either case, it seems best to tidy
the content to nothing.
* htmltidy: Avoid spewing tidy errors to stderr.
* Add %wikistate, which is like %pagestate except not specific to a given
page, and is preserved across rebuilds.
* Reorganize index file, add a format version field. Upgrades to the new
index format should be transparent.
-- Joey Hess <joeyh@debian.org> Thu, 25 Sep 2008 13:45:55 -0400

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-09-27 14:12-0400\n"
"POT-Creation-Date: 2008-09-27 16:35-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -220,20 +220,20 @@ msgstr ""
msgid "editing %s"
msgstr ""
#: ../IkiWiki/Plugin/edittemplate.pm:51
#: ../IkiWiki/Plugin/edittemplate.pm:53
msgid "template not specified"
msgstr ""
#: ../IkiWiki/Plugin/edittemplate.pm:54
#: ../IkiWiki/Plugin/edittemplate.pm:56
msgid "match not specified"
msgstr ""
#: ../IkiWiki/Plugin/edittemplate.pm:62
#: ../IkiWiki/Plugin/edittemplate.pm:64
#, perl-format
msgid "edittemplate %s registered for %s"
msgstr ""
#: ../IkiWiki/Plugin/edittemplate.pm:133
#: ../IkiWiki/Plugin/edittemplate.pm:135
msgid "failed to process"
msgstr ""
@ -910,7 +910,7 @@ msgstr ""
msgid "preprocessing loop detected on %s at depth %i"
msgstr ""
#: ../IkiWiki.pm:1614
#: ../IkiWiki.pm:1624
msgid "yes"
msgstr ""