Add force_overwrite setting to make setup automator overwrite existing files/directories.

This can be useful if you're driving the setup automator from another
program.
master
Joey Hess 2010-02-27 16:26:13 -05:00
parent 4b1da14612
commit a12c386c86
2 changed files with 14 additions and 10 deletions

View File

@ -40,17 +40,19 @@ sub import (@) {
my $this=shift; my $this=shift;
IkiWiki::Setup::merge({@_}); IkiWiki::Setup::merge({@_});
# Avoid overwriting any existing files. if (! $config{force_overwrite}) {
foreach my $key (qw{srcdir destdir repository dumpsetup}) { # Avoid overwriting any existing files.
next unless exists $config{$key}; foreach my $key (qw{srcdir destdir repository dumpsetup}) {
my $add=""; next unless exists $config{$key};
my $dir=IkiWiki::dirname($config{$key})."/"; my $add="";
my $base=IkiWiki::basename($config{$key}); my $dir=IkiWiki::dirname($config{$key})."/";
while (-e $dir.$add.$base) { my $base=IkiWiki::basename($config{$key});
$add=1 if ! $add; while (-e $dir.$add.$base) {
$add++; $add=1 if ! $add;
$add++;
}
$config{$key}=$dir.$add.$base;
} }
$config{$key}=$dir.$add.$base;
} }
# Set up wrapper # Set up wrapper

2
debian/changelog vendored
View File

@ -4,6 +4,8 @@ ikiwiki (3.20100213) UNRELEASED; urgency=low
* Rebuild wikis on upgrade to this version to get the comment counts * Rebuild wikis on upgrade to this version to get the comment counts
added to existing pages. added to existing pages.
* Loosen regexp, to allow empty quoted parameters in directives. * Loosen regexp, to allow empty quoted parameters in directives.
* Add force_overwrite setting to make setup automator overwrite existing
files/directories.
-- Joey Hess <joeyh@debian.org> Sun, 14 Feb 2010 17:02:10 -0500 -- Joey Hess <joeyh@debian.org> Sun, 14 Feb 2010 17:02:10 -0500