]> sipb.mit.edu Git - ikiwiki.git/commitdiff
avoid error if two source files render the same destination file
authorJoey Hess <joey@kitenet.net>
Sun, 18 Jul 2010 20:28:39 +0000 (16:28 -0400)
committerJoey Hess <joey@kitenet.net>
Sun, 18 Jul 2010 20:28:39 +0000 (16:28 -0400)
There are two sub-caces. If both source files still exist, the winner that
renders the destination file is undefined. If one source file is deleted
and the other added, in a refresh, the new file will take over the
destination file.

IkiWiki.pm
t/conflicts.t

index 701f7137dd78483215637e205bbde0b720ea0387..4acc5508a6ef079abd61b595a61ba6d85d117563 100644 (file)
@@ -879,7 +879,19 @@ sub will_render ($$;$) {
        # Important security check.
        if (-e "$config{destdir}/$dest" && ! $config{rebuild} &&
            ! grep { $_ eq $dest } (@{$renderedfiles{$page}}, @{$oldrenderedfiles{$page}}, @{$wikistate{editpage}{previews}})) {
-               error("$config{destdir}/$dest independently created, not overwriting with version from $page");
+               my $from_other_page=0;
+               foreach my $p (keys %renderedfiles) {
+                       if (grep {
+                               $_ eq $dest ||
+                               dirname($_) eq $dest
+                           } @{$renderedfiles{$p}}) {
+                               $from_other_page=1;
+                               last;
+                       }
+               }
+
+               error("$config{destdir}/$dest independently created, not overwriting with version from $page")
+                       unless $from_other_page;
        }
 
        if (! $clear || $cleared{$page}) {
index ac270e8062c48db261b28650faddcabb16ec678c..81b2c12cb963a8b292559cf8fb61108520077ca2 100755 (executable)
@@ -2,7 +2,7 @@
 # Tests for bugs relating to conflicting files in the srcdir
 use warnings;
 use strict;
-use Test::More tests => 48;
+use Test::More tests => 76;
 
 # setup
 my $srcdir="t/tmp/src";