Mercurial > pub > Impl
diff Lib/Deployment/Batch/Backup.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | 03e58a454b20 |
children | 76515373dac0 |
line wrap: on
line diff
--- a/Lib/Deployment/Batch/Backup.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/Deployment/Batch/Backup.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,48 +1,48 @@ -package Deployment::Batch::Backup; -use base qw(Deployment::Batch::Generic); -use Common; -use File::Copy; - -BEGIN { - DeclareProperty Action => ACCESS_READ; -} - -sub CTOR { - my ($this,$actionName,$actionArg) = @_; - - $this->{$Action} = { Name => $actionName, Arg => $actionArg }; -} - -sub Run { - my ($this) = @_; - - my $tmpObj; - - # we are in the immediate mode - if ($this->{$Action}{Name} eq 'File') { - $this->Log("Backup file: $this->{$Action}{Arg}"); - if (-e $this->{$Action}{Arg}) { - - Deployment::Batch->Temp( File => \$tmpObj ) or die "Failed to create temp file" ; - - copy ($this->{$Action}{Arg}, $tmpObj->filename) or die "Failed to backup"; - $this->{$Action}{Result} = $tmpObj->filename; - } - } else { - die "Don't know how to backup the $this->{$Action}{Name}"; - } -} - -sub Rollback { - my ($this) = @_; - if ($this->{$Action}{Name} eq 'File') { - $this->Log("Revert file: $this->{$Action}{Arg}"); - if ($this->{$Action}{Result}) { - copy ($this->{$Action}{Result}, $this->{$Action}{Arg}) or die "Failed to backup"; - } else { - unlink $this->{$Action}{Arg} if -f $this->{$Action}{Arg}; - } - } -} - -1; \ No newline at end of file +package Deployment::Batch::Backup; +use base qw(Deployment::Batch::Generic); +use Common; +use File::Copy; + +BEGIN { + DeclareProperty Action => ACCESS_READ; +} + +sub CTOR { + my ($this,$actionName,$actionArg) = @_; + + $this->{$Action} = { Name => $actionName, Arg => $actionArg }; +} + +sub Run { + my ($this) = @_; + + my $tmpObj; + + # we are in the immediate mode + if ($this->{$Action}{Name} eq 'File') { + $this->Log("Backup file: $this->{$Action}{Arg}"); + if (-e $this->{$Action}{Arg}) { + + Deployment::Batch->Temp( File => \$tmpObj ) or die "Failed to create temp file" ; + + copy ($this->{$Action}{Arg}, $tmpObj->filename) or die "Failed to backup"; + $this->{$Action}{Result} = $tmpObj->filename; + } + } else { + die "Don't know how to backup the $this->{$Action}{Name}"; + } +} + +sub Rollback { + my ($this) = @_; + if ($this->{$Action}{Name} eq 'File') { + $this->Log("Revert file: $this->{$Action}{Arg}"); + if ($this->{$Action}{Result}) { + copy ($this->{$Action}{Result}, $this->{$Action}{Arg}) or die "Failed to backup"; + } else { + unlink $this->{$Action}{Arg} if -f $this->{$Action}{Arg}; + } + } +} + +1;