mirror of https://github.com/jimsalterjrs/sanoid
nerfed most of the warnings with if defined checks
This commit is contained in:
parent
ee6c1d15e4
commit
36980d4788
14
sanoid
14
sanoid
|
|
@ -7,6 +7,7 @@
|
||||||
$::VERSION = '1.4.17';
|
$::VERSION = '1.4.17';
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use warnings;
|
||||||
use Config::IniFiles; # read samba-style conf file
|
use Config::IniFiles; # read samba-style conf file
|
||||||
use Data::Dumper; # debugging - print contents of hash
|
use Data::Dumper; # debugging - print contents of hash
|
||||||
use File::Path; # for rmtree command in use_prune
|
use File::Path; # for rmtree command in use_prune
|
||||||
|
|
@ -196,6 +197,8 @@ sub prune_snapshots {
|
||||||
elsif ($type eq 'monthly') { $period = 60*60*24*31; }
|
elsif ($type eq 'monthly') { $period = 60*60*24*31; }
|
||||||
elsif ($type eq 'yearly') { $period = 60*60*24*365.25; }
|
elsif ($type eq 'yearly') { $period = 60*60*24*365.25; }
|
||||||
|
|
||||||
|
# avoid pissing off use warnings by not executing this block if no matching snaps exist
|
||||||
|
if (defined $snapsbytype{$path}{$type}{'sorted'}) {
|
||||||
my @sorted = split (/\|/,$snapsbytype{$path}{$type}{'sorted'});
|
my @sorted = split (/\|/,$snapsbytype{$path}{$type}{'sorted'});
|
||||||
|
|
||||||
# if we say "daily=30" we really mean "don't keep any dailies more than 30 days old", etc
|
# if we say "daily=30" we really mean "don't keep any dailies more than 30 days old", etc
|
||||||
|
|
@ -238,6 +241,7 @@ sub prune_snapshots {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} # end prune_snapshots
|
} # end prune_snapshots
|
||||||
|
|
@ -512,12 +516,16 @@ sub getsnaps {
|
||||||
|
|
||||||
foreach my $snap (@rawsnaps) {
|
foreach my $snap (@rawsnaps) {
|
||||||
my ($fs,$snapname,$snapdate) = ($snap =~ m/(.*)\@(.*ly)\s*creation\s*(\d*)/);
|
my ($fs,$snapname,$snapdate) = ($snap =~ m/(.*)\@(.*ly)\s*creation\s*(\d*)/);
|
||||||
|
|
||||||
|
# avoid pissing off use warnings
|
||||||
|
if (defined $snapname) {
|
||||||
my ($snaptype) = ($snapname =~ m/.*_(\w*ly)/);
|
my ($snaptype) = ($snapname =~ m/.*_(\w*ly)/);
|
||||||
if ($snapname =~ /^autosnap/) {
|
if ($snapname =~ /^autosnap/) {
|
||||||
$snaps{$fs}{$snapname}{'ctime'}=$snapdate;
|
$snaps{$fs}{$snapname}{'ctime'}=$snapdate;
|
||||||
$snaps{$fs}{$snapname}{'type'}=$snaptype;
|
$snaps{$fs}{$snapname}{'type'}=$snaptype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return %snaps;
|
return %snaps;
|
||||||
}
|
}
|
||||||
|
|
@ -603,10 +611,10 @@ sub init {
|
||||||
# make sure that true values are true and false values are false for any toggled values
|
# make sure that true values are true and false values are false for any toggled values
|
||||||
foreach my $toggle(@toggles) {
|
foreach my $toggle(@toggles) {
|
||||||
foreach my $true (@istrue) {
|
foreach my $true (@istrue) {
|
||||||
if ($config{$section}{$toggle} eq $true) { $config{$section}{$toggle} = 1; }
|
if (defined $config{$section}{$toggle} && $config{$section}{$toggle} eq $true) { $config{$section}{$toggle} = 1; }
|
||||||
}
|
}
|
||||||
foreach my $false (@isfalse) {
|
foreach my $false (@isfalse) {
|
||||||
if ($config{$section}{$toggle} eq $false) { $config{$section}{$toggle} = 0; }
|
if (defined $config{$section}{$toggle} && $config{$section}{$toggle} eq $false) { $config{$section}{$toggle} = 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1031,7 +1039,7 @@ sub iszfsbusy {
|
||||||
sub getchilddatasets {
|
sub getchilddatasets {
|
||||||
# for later, if we make sanoid itself support sudo use
|
# for later, if we make sanoid itself support sudo use
|
||||||
my $fs = shift;
|
my $fs = shift;
|
||||||
my $mysudocmd;
|
my $mysudocmd = '';
|
||||||
|
|
||||||
my $getchildrencmd = "$mysudocmd $zfs list -o name -Hr $fs |";
|
my $getchildrencmd = "$mysudocmd $zfs list -o name -Hr $fs |";
|
||||||
if ($args{'debug'}) { print "DEBUG: getting list of child datasets on $fs using $getchildrencmd...\n"; }
|
if ($args{'debug'}) { print "DEBUG: getting list of child datasets on $fs using $getchildrencmd...\n"; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue