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
parent
8d04a1de61
commit
61426a7186
48
IkiWiki.pm
48
IkiWiki.pm
|
@ -1309,31 +1309,40 @@ sub loadindex () { #{{{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $ret=Storable::fd_retrieve($in);
|
|
||||||
if (! defined $ret) {
|
my $index=Storable::fd_retrieve($in);
|
||||||
|
if (! defined $index) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
my %index=%$ret;
|
|
||||||
foreach my $src (keys %index) {
|
my $pages;
|
||||||
my %d=%{$index{$src}};
|
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);
|
my $page=pagename($src);
|
||||||
$pagectime{$page}=$d{ctime};
|
$pagectime{$page}=$d->{ctime};
|
||||||
if (! $config{rebuild}) {
|
if (! $config{rebuild}) {
|
||||||
$pagesources{$page}=$src;
|
$pagesources{$page}=$src;
|
||||||
$pagemtime{$page}=$d{mtime};
|
$pagemtime{$page}=$d->{mtime};
|
||||||
$renderedfiles{$page}=$d{dest};
|
$renderedfiles{$page}=$d->{dest};
|
||||||
if (exists $d{links} && ref $d{links}) {
|
if (exists $d->{links} && ref $d->{links}) {
|
||||||
$links{$page}=$d{links};
|
$links{$page}=$d->{links};
|
||||||
$oldlinks{$page}=[@{$d{links}}];
|
$oldlinks{$page}=[@{$d->{links}}];
|
||||||
}
|
}
|
||||||
if (exists $d{depends}) {
|
if (exists $d->{depends}) {
|
||||||
$depends{$page}=$d{depends};
|
$depends{$page}=$d->{depends};
|
||||||
}
|
}
|
||||||
if (exists $d{state}) {
|
if (exists $d->{state}) {
|
||||||
$pagestate{$page}=$d{state};
|
$pagestate{$page}=$d->{state};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$oldrenderedfiles{$page}=[@{$d{dest}}];
|
$oldrenderedfiles{$page}=[@{$d->{dest}}];
|
||||||
}
|
}
|
||||||
foreach my $page (keys %pagesources) {
|
foreach my $page (keys %pagesources) {
|
||||||
$pagecase{lc $page}=$page;
|
$pagecase{lc $page}=$page;
|
||||||
|
@ -1364,7 +1373,7 @@ sub saveindex () { #{{{
|
||||||
next unless $pagemtime{$page};
|
next unless $pagemtime{$page};
|
||||||
my $src=$pagesources{$page};
|
my $src=$pagesources{$page};
|
||||||
|
|
||||||
$index{$src}={
|
$index{page}{$src}={
|
||||||
ctime => $pagectime{$page},
|
ctime => $pagectime{$page},
|
||||||
mtime => $pagemtime{$page},
|
mtime => $pagemtime{$page},
|
||||||
dest => $renderedfiles{$page},
|
dest => $renderedfiles{$page},
|
||||||
|
@ -1372,17 +1381,18 @@ sub saveindex () { #{{{
|
||||||
};
|
};
|
||||||
|
|
||||||
if (exists $depends{$page}) {
|
if (exists $depends{$page}) {
|
||||||
$index{$src}{depends} = $depends{$page};
|
$index{page}{$src}{depends} = $depends{$page};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exists $pagestate{$page}) {
|
if (exists $pagestate{$page}) {
|
||||||
foreach my $id (@hookids) {
|
foreach my $id (@hookids) {
|
||||||
foreach my $key (keys %{$pagestate{$page}{$id}}) {
|
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);
|
my $ret=Storable::nstore_fd(\%index, $out);
|
||||||
return if ! defined $ret || ! $ret;
|
return if ! defined $ret || ! $ret;
|
||||||
close $out || error("failed saving to $newfile: $!", $cleanup);
|
close $out || error("failed saving to $newfile: $!", $cleanup);
|
||||||
|
|
|
@ -16,6 +16,8 @@ sub import { #{{{
|
||||||
call => \&preprocess);
|
call => \&preprocess);
|
||||||
hook(type => "formbuilder", id => "edittemplate",
|
hook(type => "formbuilder", id => "edittemplate",
|
||||||
call => \&formbuilder);
|
call => \&formbuilder);
|
||||||
|
hook(type => "refresh", id => "edittemplate",
|
||||||
|
call => \&refresh);
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
sub getsetup () { #{{{
|
sub getsetup () { #{{{
|
||||||
|
@ -138,4 +140,8 @@ sub filltemplate ($$) { #{{{
|
||||||
return $template->output;
|
return $template->output;
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
|
sub refresh () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
1
|
1
|
||||||
|
|
|
@ -19,6 +19,10 @@ ikiwiki (2.66) UNRELEASED; urgency=low
|
||||||
untidied content if tidy crashes. In either case, it seems best to tidy
|
untidied content if tidy crashes. In either case, it seems best to tidy
|
||||||
the content to nothing.
|
the content to nothing.
|
||||||
* htmltidy: Avoid spewing tidy errors to stderr.
|
* 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
|
-- Joey Hess <joeyh@debian.org> Thu, 25 Sep 2008 13:45:55 -0400
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -220,20 +220,20 @@ msgstr ""
|
||||||
msgid "editing %s"
|
msgid "editing %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/Plugin/edittemplate.pm:51
|
#: ../IkiWiki/Plugin/edittemplate.pm:53
|
||||||
msgid "template not specified"
|
msgid "template not specified"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/Plugin/edittemplate.pm:54
|
#: ../IkiWiki/Plugin/edittemplate.pm:56
|
||||||
msgid "match not specified"
|
msgid "match not specified"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/Plugin/edittemplate.pm:62
|
#: ../IkiWiki/Plugin/edittemplate.pm:64
|
||||||
#, perl-format
|
#, perl-format
|
||||||
msgid "edittemplate %s registered for %s"
|
msgid "edittemplate %s registered for %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki/Plugin/edittemplate.pm:133
|
#: ../IkiWiki/Plugin/edittemplate.pm:135
|
||||||
msgid "failed to process"
|
msgid "failed to process"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -910,7 +910,7 @@ msgstr ""
|
||||||
msgid "preprocessing loop detected on %s at depth %i"
|
msgid "preprocessing loop detected on %s at depth %i"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../IkiWiki.pm:1614
|
#: ../IkiWiki.pm:1624
|
||||||
msgid "yes"
|
msgid "yes"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue