handle the case of mistyped dataset name nicely

This commit is contained in:
Christoph Klaffl 2019-01-25 23:46:58 +01:00
parent 9ec0c0bfb1
commit 85561ddcda
No known key found for this signature in database
GPG Key ID: FC1C525C2A47CC28
1 changed files with 12 additions and 1 deletions

13
syncoid
View File

@ -263,6 +263,12 @@ sub syncdataset {
my $sync = getzfsvalue($sourcehost,$sourcefs,$sourceisroot,'syncoid:sync');
if (!defined $sync) {
# zfs already printed the corresponding error
if ($exitcode < 2) { $exitcode = 2; }
return 0;
}
if ($sync eq 'true' || $sync eq '-' || $sync eq '') {
# empty is handled the same as unset (aka: '-')
# definitely sync this dataset - if a host is called 'true' or '-', then you're special
@ -978,6 +984,11 @@ sub getzfsvalue {
open FH, "$rhost $mysudocmd $zfscmd get -H $property $fsescaped |";
my $value = <FH>;
close FH;
if (!defined $value) {
return undef;
}
my @values = split(/\t/,$value);
$value = $values[2];
return $value;
@ -1468,7 +1479,7 @@ sub getreceivetoken() {
my ($rhost,$fs,$isroot) = @_;
my $token = getzfsvalue($rhost,$fs,$isroot,"receive_resume_token");
if ($token ne '-' && $token ne '') {
if (defined $token && $token ne '-' && $token ne '') {
return $token;
}