浏览代码

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>
Sebastiaan van Stijn 4 年之前
父节点
当前提交
7e907e29a3
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      volume/local/local.go

+ 5 - 3
volume/local/local.go

@@ -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
 	}