]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/aggregate.pm
changes to debug message printing
[ikiwiki.git] / IkiWiki / Plugin / aggregate.pm
index 4fbcde390d59fd232f9fbfaf63f358259f74b423..1f09c988b8ab8bdf05bd6ba2cad4bf787d904a42 100644 (file)
@@ -113,6 +113,48 @@ sub launchaggregation () { #{{{
        return 1;
 } #}}}
 
+# Used by ikiwiki-transition aggregateinternal.
+sub migrate_to_internal { #{{{
+       if (! lockaggregate()) {
+               error("an aggregation process is currently running");
+       }
+
+       IkiWiki::lockwiki();
+       loadstate();
+       $config{verbose}=1;
+
+       foreach my $data (values %guids) {
+               next unless $data->{page};
+               
+               $config{aggregateinternal} = 0;
+               my $oldname = pagefile($data->{page});
+               
+               $config{aggregateinternal} = 1;
+               my $newname = pagefile($data->{page});
+               
+               debug "moving $oldname -> $newname";
+               if (-e $newname) {
+                       if (-e $oldname) {
+                               error("$newname already exists");
+                       }
+                       else {
+                               debug("already renamed to $newname?");
+                       }
+               }
+               elsif (-e $oldname) {
+                       rename($oldname, $newname) || error("$!");
+               }
+               else {
+                       debug("$oldname not found");
+               }
+       }
+       
+       savestate();
+       IkiWiki::unlockwiki;
+       
+       unlockaggregate();
+} #}}}
+
 sub needsbuild (@) { #{{{
        my $needsbuild=shift;
        
@@ -134,7 +176,7 @@ sub preprocess (@) { #{{{
 
        foreach my $required (qw{name url}) {
                if (! exists $params{$required}) {
-                       return "[[aggregate ".sprintf(gettext("missing %s parameter"), $required)."]]";
+                       error sprintf(gettext("missing %s parameter"), $required)
                }
        }