more comments, support for txt and pod upgrade files

This commit is contained in:
Graham Knop 2010-05-18 20:34:52 -05:00
parent 29c01ffad7
commit 8326c63c1e
9 changed files with 201 additions and 142 deletions

View file

@ -9,6 +9,7 @@ use Try::Tiny;
use File::Spec;
use File::Path qw(make_path);
use POSIX qw(strftime);
use Cwd ();
use namespace::autoclean;
has quiet => (
@ -39,6 +40,10 @@ has backupPath => (
is => 'rw',
default => File::Spec->catdir(File::Spec->tmpdir, 'backups'),
);
has _files_run => (
is => 'rw',
default => sub { { } },
);
sub upgradeSites {
my $self = shift;
@ -155,15 +160,19 @@ sub runUpgradeStep {
sub runUpgradeFile {
my $self = shift;
my ($configFile, $version, $filename, $quiet) = @_;
my ($configFile, $version, $filename) = @_;
my $has_run = $self->_files_run->{ Cwd::realpath($filename) } ++;
my ($extension) = $filename =~ /\.([^.]+)$/;
return
unless $extension;
my $package = 'WebGUI::Upgrade::File::' . $extension;
if ( try { WebGUI::Pluggable::load($package) } && $package->can('run') ) {
return $package->run($configFile, $version, $filename, $self->quiet);
if ( try { WebGUI::Pluggable::load($package) } && $package->DOES('WebGUI::Upgrade::File') ) {
if ($has_run && $package->once) {
return;
}
return $package->run($self, $configFile, $version, $filename);
}
warn "Don't know how to use $extension upgrade file\n";
return;
@ -248,6 +257,9 @@ sub dbhForConfig {
sub mysqlCommandLine {
my $class = shift;
my $config = shift;
if (! ref $config) {
$config = WebGUI::Config->new($config, 1);
}
my $dsn = $config->get('dsn');
my $username = $config->get('dbuser');