diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2009-05-06 20:46:26 -0400 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-05-06 20:46:26 -0400 |
commit | 9f5f5543bf74362cacaa7eec10d9116b41b8179d (patch) | |
tree | 09f0081bc6d0fe8b930625282e5a90dd63419f00 /ikiwiki-transition | |
parent | fdfaa1b515b68573d4adfaf358284ec77fbff24a (diff) |
ikiwiki-transition: If passed a nonexistant srcdir, or one not containing .ikiwiki, abort with an error rather than creating it.
Diffstat (limited to 'ikiwiki-transition')
-rwxr-xr-x | ikiwiki-transition | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/ikiwiki-transition b/ikiwiki-transition index f17868d73..ce1807309 100755 --- a/ikiwiki-transition +++ b/ikiwiki-transition @@ -73,11 +73,7 @@ sub prefix_directives { } sub indexdb { - my $dir=shift; - if (! defined $dir) { - usage(); - } - $config{wikistatedir}=$dir."/.ikiwiki"; + setstatedir(shift); # Note: No lockwiki here because ikiwiki already locks it # before calling this. @@ -96,11 +92,7 @@ sub indexdb { } sub hashpassword { - my $dir=shift; - if (! defined $dir) { - usage(); - } - $config{wikistatedir}=$dir."/.ikiwiki"; + setstatedir(shift); eval q{use IkiWiki::UserInfo}; eval q{use Authen::Passphrase::BlowfishCrypt}; @@ -221,11 +213,7 @@ sub moveprefs { } sub deduplinks { - my $dir=shift; - if (! defined $dir) { - usage(); - } - $config{wikistatedir}=$dir."/.ikiwiki"; + setstatdir(shift); IkiWiki::loadindex(); foreach my $page (keys %links) { my %l; @@ -235,6 +223,24 @@ sub deduplinks { IkiWiki::saveindex(); } +sub setstatedir { + my $dir=shift; + + if (! defined $dir) { + usage(); + } + + if (! -d $dir) { + error("ikiwiki-transition: $dir does not exist"); + } + + $config{wikistatedir}=$dir."/.ikiwiki"; + + if (! -d $config{wikistatedir}) { + error("ikiwiki-transition: $config{wikistatedir} does not exist"); + } +} + sub usage { print STDERR "Usage: ikiwiki-transition type ...\n"; print STDERR "Currently supported transition subcommands:\n"; |