Changeset dcf68ec13d20584470c074ebed23476fcfe3f3f4

Show
Ignore:
Timestamp:
08/04/09 15:24:07 (9 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1249399447 +0000
git-parent:

[aefc6b700fa924a64f3cf710fdb0040f89ee4c05]

git-author:
Mark Harrison <mark@omniti.com> 1249399447 +0000
Message:

Fix behavior when no amount is specified, and better parsing of the policy

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • zetaback.in

    raefc6b7 rdcf68ec  
    768768 
    769769    # Process retention policy 
    770     my %parts = split(/[;,]/, $retention); 
    771     my @periods = sort { $a <=> $b } keys(%parts); 
     770    my @parts = split(/;/, $retention); 
     771    my %retention_map; 
     772    foreach (@parts) { 
     773      my ($period, $amount) = split(/,/); 
     774      if (!defined($amount)) { 
     775        $amount = -1; 
     776      } 
     777      $retention_map{$period} = $amount; 
     778    } 
     779    my @periods = sort { $a <=> $b } keys(%retention_map); 
    772780    my %backup_bins; 
    773781    foreach(@periods) { 
     
    795803    } 
    796804    foreach (keys(%backup_bins)) { 
    797       my $keep = $parts{$_}; # How many backups to keep 
    798       if (!$keep) { next; }  # Don't keep any backups if none specified 
     805      my $keep = $retention_map{$_}; # How many backups to keep 
    799806      if ($backup_bins{$_}) { 
    800807        my @backups = @{$backup_bins{$_}}; 
    801808        my $total = @backups;  # How many backups we have 
     809        # If we didn't specify how many to keep, keep them all 
     810        if ($keep == -1) { $keep = $total }; 
    802811        # If we have less backups than we should keep, keep them all 
    803812        if ($total < $keep) { $keep = $total };