+sub disable_commit_hook () { #{{{
+ open($commitlock, '>', "$config{wikistatedir}/commitlock") ||
+ error("cannot write to $config{wikistatedir}/commitlock: $!");
+ if (! flock($commitlock, 2)) { # LOCK_EX
+ error("failed to get commit lock");
+ }
+ return 1;
+} #}}}
+
+sub enable_commit_hook () { #{{{
+ return close($commitlock) if $commitlock;
+ return;
+} #}}}
+
+sub loadindex () { #{{{
+ %oldrenderedfiles=%pagectime=();
+ if (! $config{rebuild}) {
+ %pagesources=%pagemtime=%oldlinks=%links=%depends=
+ %destsources=%renderedfiles=%pagecase=%pagestate=();
+ }
+ 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 $src (keys %index) {
+ my %d=%{$index{$src}};
+ my $page=pagename($src);
+ $pagectime{$page}=$d{ctime};