فهرست منبع

pkg/system.EnsureRemoveAll: don't call Mounted

1. Call to mount.Mounted() is very expensive and it's redundant
   to call it before Unmount().

2. Calling mount.Mounted() after an error from Unmount() is
   questionable -- if umount failed, the mount is probably
   still there anyway, it doesn't make sense to check it.

This should result in faster code with no change in functionality.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Kir Kolyshkin 5 سال پیش
والد
کامیت
f8dbc31b78
1فایلهای تغییر یافته به همراه2 افزوده شده و 6 حذف شده
  1. 2 6
      pkg/system/rm.go

+ 2 - 6
pkg/system/rm.go

@@ -63,12 +63,8 @@ func EnsureRemoveAll(dir string) error {
 			return err
 		}
 
-		if mounted, _ := mount.Mounted(pe.Path); mounted {
-			if e := mount.Unmount(pe.Path); e != nil {
-				if mounted, _ := mount.Mounted(pe.Path); mounted {
-					return errors.Wrapf(e, "error while removing %s", dir)
-				}
-			}
+		if e := mount.Unmount(pe.Path); e != nil {
+			return errors.Wrapf(e, "error while removing %s", dir)
 		}
 
 		if exitOnErr[pe.Path] == maxRetry {