List only configured datasets

This commit is contained in:
Goran Mekić 2025-03-10 15:47:19 +01:00
parent bae2bd2601
commit 5f501fdca9

View File

@ -68,9 +68,21 @@ func ZFSListMappingProperties(ctx context.Context, filter DatasetFilter, propert
defer cancel()
rchan := make(chan ZFSListResult)
go ZFSListChan(ctx, rchan, properties, nil, "-r", "-t", "filesystem,volume")
args := []string{"-r", "-t", "filesystem,volume"}
unmatchedUserSpecifiedDatasets := filter.UserSpecifiedDatasets()
for ds, _ := range unmatchedUserSpecifiedDatasets {
var path *DatasetPath
if path, err = NewDatasetPath(ds); err != nil {
return
}
if ph, err := ZFSGetFilesystemPlaceholderState(ctx, path); err == nil && ph.FSExists {
args = append(args, ds)
delete(unmatchedUserSpecifiedDatasets, path.ToString())
}
}
err = nil
go ZFSListChan(ctx, rchan, properties, nil, args...)
datasets = make([]ZFSListMappingPropertiesResult, 0)
for r := range rchan {
@ -84,8 +96,6 @@ func ZFSListMappingProperties(ctx context.Context, filter DatasetFilter, propert
return
}
delete(unmatchedUserSpecifiedDatasets, path.ToString())
pass, filterErr := filter.Filter(path)
if filterErr != nil {
return nil, fmt.Errorf("error calling filter: %s", filterErr)