volume/local.New() always unmount existing mounts

Unmounting does not depend on wether or not loading options failed.

This code-path seemed to be used as a "hack" to prevent hitting the
unmount on Windows (which does not support unmounting).

Moving it outside of the "if" to make more clear that it's independent
of loading the options.

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

View file

@ -78,6 +78,11 @@ func New(scope string, rootIdentity idtools.Identity) (*Root, error) {
path: filepath.Join(r.path, name, volumeDataPathName),
quotaCtl: r.quotaCtl,
}
// unmount anything that may still be mounted (for example, from an
// unclean shutdown). This is a no-op on windows
unmount(v.path)
if b, err := os.ReadFile(filepath.Join(v.rootPath, "opts.json")); err == nil {
opts := optsConfig{}
if err := json.Unmarshal(b, &opts); err != nil {
@ -88,9 +93,6 @@ func New(scope string, rootIdentity idtools.Identity) (*Root, error) {
if !reflect.DeepEqual(opts, optsConfig{}) {
v.opts = &opts
}
// unmount anything that may still be mounted (for example, from an
// unclean shutdown). This is a no-op on windows
unmount(v.path)
}
r.volumes[name] = v
}