Changeset 107 for trunk

Show
Ignore:
Timestamp:
04/08/10 23:18:23 (4 years ago)
Author:
depesz
Message:

1. Logger is smart enough, I can pass references, and it will do whatever is necessary with them. No need for Dumper.
2. In case of non-segment files (i.e. .backup files) checking for size is not going to work

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/omnipitr/lib/OmniPITR/Program/Archive.pm

    r106 r107  
    160160 
    161161        if ( $response->{ 'error_code' } ) { 
    162             $self->log->fatal( 'Error while compressing with %s : %s', $compression, Dumper( $response ) ); 
     162            $self->log->fatal( 'Error while compressing with %s : %s', $compression, $response ); 
    163163        } 
    164164 
     
    370370    } 
    371371 
    372     $self->log->fatal( 'Given segment name is not valid (%s)', $self->{ 'segment' } ) unless basename( $self->{ 'segment' } ) =~ m{\A[a-fA-F0-9]{24}\z}; 
     372    $self->log->fatal( 'Given segment name is not valid (%s)', $self->{ 'segment' } ) unless basename( $self->{ 'segment' } ) =~ m{\A[a-fA-F0-9]{24}(?:\.[a-fA-F0-9]{8}\.backup)?\z}; 
    373373    my $segment_file_name = $self->{ 'segment' }; 
    374374    $segment_file_name = File::Spec->catfile( $self->{ 'data-dir' }, $self->{ 'segment' } ) unless $self->{ 'segment' } =~ m{^/}; 
     
    378378    $self->log->fatal( 'Given segment (%s) is not readable.', $segment_file_name ) unless -r $segment_file_name; 
    379379 
    380     my $expected_size = 256**3; 
    381     my $file_size     = ( -s $segment_file_name ); 
    382     $self->log->fatal( 'Given segment (%s) has incorrect size (%u vs %u).', $segment_file_name, $file_size, $expected_size ) unless $expected_size == $file_size; 
     380    unless ( $self->{ 'segment' } =~ m{\.backup\z} ) { 
     381        my $expected_size = 256**3; 
     382        my $file_size     = ( -s $segment_file_name ); 
     383        $self->log->fatal( 'Given segment (%s) has incorrect size (%u vs %u).', $segment_file_name, $file_size, $expected_size ) unless $expected_size == $file_size; 
     384    } 
    383385 
    384386    $self->{ 'segment' } = $segment_file_name;