mirror of https://github.com/jimsalterjrs/sanoid
fixed file handle conflict
This commit is contained in:
parent
940a84e21f
commit
efd52f416d
15
sanoid
15
sanoid
|
|
@ -1084,11 +1084,9 @@ sub init {
|
|||
@datasets = getchilddatasets($config{$section}{'path'});
|
||||
DATASETS: foreach my $dataset(@datasets) {
|
||||
if (! @cachedatasets) {
|
||||
push (@updatedatasets, $dataset);
|
||||
push (@updatedatasets, "$dataset\n");
|
||||
}
|
||||
|
||||
chomp $dataset;
|
||||
|
||||
if ($zfsRecursive) {
|
||||
# don't try to take the snapshot ourself, recursive zfs snapshot will take care of that
|
||||
$config{$dataset}{'autosnap'} = 0;
|
||||
|
|
@ -1691,7 +1689,7 @@ sub getchilddatasets {
|
|||
my $getchildrencmd = "$mysudocmd $zfs list -o name -t filesystem,volume -Hr $fs |";
|
||||
if ($args{'debug'}) { print "DEBUG: getting list of child datasets on $fs using $getchildrencmd...\n"; }
|
||||
open FH, $getchildrencmd;
|
||||
my @children = <FH>;
|
||||
chomp( my @children = <FH> );
|
||||
close FH;
|
||||
|
||||
# parent dataset is the first element
|
||||
|
|
@ -1781,25 +1779,26 @@ sub addcachedsnapshots {
|
|||
|
||||
copy($cache, "$cache.tmp") or die "Could not copy to $cache.tmp!\n";
|
||||
|
||||
open FH, ">> $cache.tmp" or die "Could not write to $cache.tmp!\n";
|
||||
open my $fh, ">> $cache.tmp" or die "Could not write to $cache.tmp!\n";
|
||||
while((my $snap, my $details) = each(%taken)) {
|
||||
my @parts = split("@", $snap, 2);
|
||||
|
||||
my $suffix = $parts[1] . "\tcreation\t" . $details->{time} . "\t-";
|
||||
my $dataset = $parts[0];
|
||||
|
||||
print FH "${dataset}\@${suffix}\n";
|
||||
print $fh "${dataset}\@${suffix}\n";
|
||||
|
||||
if ($details->{recursive}) {
|
||||
my @datasets = getchilddatasets($dataset);
|
||||
|
||||
foreach my $dataset(@datasets) {
|
||||
print FH "${dataset}\@${suffix}\n";
|
||||
print "${dataset}\@${suffix}\n";
|
||||
print $fh "${dataset}\@${suffix}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close FH;
|
||||
close $fh;
|
||||
|
||||
# preserve mtime of cache for expire check
|
||||
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($cache);
|
||||
|
|
|
|||
Loading…
Reference in New Issue