volume/local.New(): don't register volume before we're done

Loading options may fail, in which case we don't have to add
the volume to the list.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-10-08 00:40:47 +02:00
parent eecf7a0840
commit b56fc2d0f8
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -78,7 +78,6 @@ func New(scope string, rootIdentity idtools.Identity) (*Root, error) {
path: r.DataPath(name), path: r.DataPath(name),
quotaCtl: r.quotaCtl, quotaCtl: r.quotaCtl,
} }
r.volumes[name] = v
if b, err := os.ReadFile(filepath.Join(r.path, name, "opts.json")); err == nil { if b, err := os.ReadFile(filepath.Join(r.path, name, "opts.json")); err == nil {
opts := optsConfig{} opts := optsConfig{}
if err := json.Unmarshal(b, &opts); err != nil { if err := json.Unmarshal(b, &opts); err != nil {
@ -93,6 +92,7 @@ func New(scope string, rootIdentity idtools.Identity) (*Root, error) {
// unclean shutdown). This is a no-op on windows // unclean shutdown). This is a no-op on windows
unmount(v.path) unmount(v.path)
} }
r.volumes[name] = v
} }
return r, nil return r, nil