X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FStorage%2FText.pm;h=5c60cf6b60509cc15fd7ee1e3f006a2e30259c44;hp=72b2fba33f683e578a75b28f111a4c9a770bb6f8;hb=fda25dc88a63ccac1c80efa2e4994bf0725ca9b7;hpb=df717077755b9331fa245f72933ef03add7a3710 diff --git a/lib/BackupPC/Storage/Text.pm b/lib/BackupPC/Storage/Text.pm index 72b2fba..5c60cf6 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-2007 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.0beta1, released 30 Jul 2006. +# Version 3.1.0, released 25 Nov 2007. # # 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; } @@ -279,6 +291,7 @@ sub ConfigDataRead } %$conf = ( %$conf, %Conf ); } + # # Promote BackupFilesOnly and BackupFilesExclude to hashes # @@ -330,10 +343,7 @@ sub ConfigFileMerge { my($s, $inFile, $newConf) = @_; local(*C); - my($contents, $out); - my $comment = 1; - my $skipVar = 0; - my $endLine = undef; + my($contents, $skipExpr, $fakeVar); my $done = {}; if ( -f $inFile ) { @@ -345,12 +355,10 @@ sub ConfigFileMerge binmode(C); while ( ) { - if ( $comment && /^\s*#/ ) { - $out .= $_; - } elsif ( /^\s*\$Conf\{([^}]*)\}\s*=/ ) { + if ( /^\s*\$Conf\{([^}]*)\}\s*=(.*)/ ) { my $var = $1; - if ( exists($newConf->{$var}) ) { - $contents .= $out; + $skipExpr = "\$fakeVar = $2\n"; + if ( exists($newConf->{$var}) ) { my $d = Data::Dumper->new([$newConf->{$var}], [*value]); $d->Indent(1); $d->Terse(1); @@ -359,31 +367,24 @@ sub ConfigFileMerge $contents .= "\$Conf{$var} = " . $value; $done->{$var} = 1; } - if ( /^\s*\$Conf\{[^}]*} *= *<<(.*);/ - || /^\s*\$Conf\{[^}]*} *= *<<'(.*)';/ ) { - $endLine = $1; - $skipVar = 1; - } else { - $endLine = undef; - $skipVar = /^[^#]*;/ ? 0 : 1; - } - $out = ""; - } elsif ( $skipVar ) { - if ( !defined($endLine) && /^[^#]*;/ ) { - $skipVar = 0; - $comment = 1; - } - if ( defined($endLine) && /^\Q$endLine\E[\n\r]*$/ ) { - $endLine = undef; - $skipVar = 0; - $comment = 1; - } + } elsif ( defined($skipExpr) ) { + $skipExpr .= $_; } else { - $out .= $_; + $contents .= $_; + } + if ( defined($skipExpr) + && ($skipExpr =~ /^\$fakeVar = *<