X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FStorage%2FText.pm;h=0f22932c25da213467798c04a269cdd1f1654438;hp=8a8b528f9a134f0333a18313ac6f5d16b27bd89c;hb=ca593f66fd6c35764bd8997c6338b781330f019c;hpb=b81d2da5e16975674f011e4833337ac0fa24e0ea diff --git a/lib/BackupPC/Storage/Text.pm b/lib/BackupPC/Storage/Text.pm index 8a8b528..0f22932 100644 --- a/lib/BackupPC/Storage/Text.pm +++ b/lib/BackupPC/Storage/Text.pm @@ -12,7 +12,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2004 Craig Barratt +# Copyright (C) 2004-2009 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 11 Nov 2006. +# Version 3.2.0beta0, released 5 April 2009. # # See http://backuppc.sourceforge.net. # @@ -84,6 +84,18 @@ sub BackupInfoRead close(BK_INFO); } close(LOCK); + # + # Default the version field. Prior to 3.0.0 the xferMethod + # field is empty, so we use that to figure out the version. + # + for ( my $i = 0 ; $i < @Backups ; $i++ ) { + next if ( $Backups[$i]{version} ne "" ); + if ( $Backups[$i]{xferMethod} eq "" ) { + $Backups[$i]{version} = "2.1.2"; + } else { + $Backups[$i]{version} = "3.0.0"; + } + } return @Backups; } @@ -202,7 +214,10 @@ sub TextFileWrite (my $dir = $file) =~ s{(.+)/(.+)}{$1}; - mkpath($dir, 0, 0775) if ( !-d $dir ); + if ( !-d $dir ) { + eval { mkpath($dir, 0, 0775) }; + return "TextFileWrite: can't create directory $dir" if ( $@ ); + } if ( open(FD, ">", "$file.new") ) { binmode(FD); print FD $contents; @@ -259,26 +274,27 @@ sub ConfigPath sub ConfigDataRead { - my($s, $host) = @_; + my($s, $host, $prevConfig) = @_; my($ret, $mesg, $config, @configs); # # TODO: add lock # - my $conf = {}; + my $conf = $prevConfig || {}; my $configPath = $s->ConfigPath($host); push(@configs, $configPath) if ( -f $configPath ); foreach $config ( @configs ) { - %Conf = (); + %Conf = %$conf; if ( !defined($ret = do $config) && ($! || $@) ) { $mesg = "Couldn't open $config: $!" if ( $! ); $mesg = "Couldn't execute $config: $@" if ( $@ ); $mesg =~ s/[\n\r]+//; return ($mesg, $conf); } - %$conf = ( %$conf, %Conf ); + %$conf = %Conf; } + # # Promote BackupFilesOnly and BackupFilesExclude to hashes # @@ -344,8 +360,8 @@ sub ConfigFileMerge while ( ) { if ( /^\s*\$Conf\{([^}]*)\}\s*=(.*)/ ) { my $var = $1; + $skipExpr = "\$fakeVar = $2\n"; if ( exists($newConf->{$var}) ) { - $skipExpr = "\$fakeVar = $2\n"; my $d = Data::Dumper->new([$newConf->{$var}], [*value]); $d->Indent(1); $d->Terse(1); @@ -359,11 +375,14 @@ sub ConfigFileMerge } else { $contents .= $_; } - if ( defined($skipExpr) ) { + if ( defined($skipExpr) + && ($skipExpr =~ /^\$fakeVar = *<