mirror of
https://github.com/zrepl/zrepl.git
synced 2025-08-10 15:37:35 +02:00
zfs: fix half-nil error reporting of dataset-does-not-exist for ZFSListChan and ZFSBookmark
This commit is contained in:
16
zfs/zfs.go
16
zfs/zfs.go
@ -276,14 +276,12 @@ func ZFSListChan(ctx context.Context, out chan ZFSListResult, properties []strin
|
|||||||
}
|
}
|
||||||
if err := cmd.Wait(); err != nil {
|
if err := cmd.Wait(); err != nil {
|
||||||
if _, ok := err.(*exec.ExitError); ok {
|
if _, ok := err.(*exec.ExitError); ok {
|
||||||
enotexist := func() error {
|
var enotexist *DatasetDoesNotExist
|
||||||
if notExistHint == nil {
|
if notExistHint != nil {
|
||||||
return nil
|
enotexist = tryDatasetDoesNotExist(notExistHint.ToString(), stderrBuf.Bytes())
|
||||||
}
|
|
||||||
return tryDatasetDoesNotExist(notExistHint.ToString(), stderrBuf.Bytes())
|
|
||||||
}
|
}
|
||||||
if err := enotexist(); err != nil {
|
if enotexist != nil {
|
||||||
sendResult(nil, err)
|
sendResult(nil, enotexist)
|
||||||
} else {
|
} else {
|
||||||
sendResult(nil, &ZFSError{
|
sendResult(nil, &ZFSError{
|
||||||
Stderr: stderrBuf.Bytes(),
|
Stderr: stderrBuf.Bytes(),
|
||||||
@ -1372,7 +1370,7 @@ type DatasetDoesNotExist struct {
|
|||||||
|
|
||||||
func (d *DatasetDoesNotExist) Error() string { return fmt.Sprintf("dataset %q does not exist", d.Path) }
|
func (d *DatasetDoesNotExist) Error() string { return fmt.Sprintf("dataset %q does not exist", d.Path) }
|
||||||
|
|
||||||
func tryDatasetDoesNotExist(expectPath string, stderr []byte) error {
|
func tryDatasetDoesNotExist(expectPath string, stderr []byte) *DatasetDoesNotExist {
|
||||||
if sm := zfsGetDatasetDoesNotExistRegexp.FindSubmatch(stderr); sm != nil {
|
if sm := zfsGetDatasetDoesNotExistRegexp.FindSubmatch(stderr); sm != nil {
|
||||||
if string(sm[1]) == expectPath {
|
if string(sm[1]) == expectPath {
|
||||||
return &DatasetDoesNotExist{expectPath}
|
return &DatasetDoesNotExist{expectPath}
|
||||||
@ -1650,7 +1648,7 @@ func ZFSBookmark(ctx context.Context, fs string, v ZFSSendArgVersion, bookmark s
|
|||||||
cmd := zfscmd.CommandContext(ctx, ZFS_BINARY, "bookmark", snapname, bookmarkname)
|
cmd := zfscmd.CommandContext(ctx, ZFS_BINARY, "bookmark", snapname, bookmarkname)
|
||||||
stdio, err := cmd.CombinedOutput()
|
stdio, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if ddne := tryDatasetDoesNotExist(snapname, stdio); err != nil {
|
if ddne := tryDatasetDoesNotExist(snapname, stdio); ddne != nil {
|
||||||
return ddne
|
return ddne
|
||||||
} else if zfsBookmarkExistsRegex.Match(stdio) {
|
} else if zfsBookmarkExistsRegex.Match(stdio) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user