Remove redundant "os.IsNotExist" checks on os.RemoveAll()

`os.RemoveAll()` should never return this error. From the docs:

> If the path does not exist, RemoveAll returns nil (no error).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-09-23 10:30:53 +02:00
parent a24a71c50f
commit 7335167340
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 4 additions and 4 deletions

View file

@ -331,7 +331,7 @@ func (daemon *Daemon) cleanupSecretDir(c *container.Container) {
if err := mount.RecursiveUnmount(dir); err != nil {
logrus.WithField("dir", dir).WithError(err).Warn("Error while attempting to unmount dir, this may prevent removal of container.")
}
if err := os.RemoveAll(dir); err != nil && !os.IsNotExist(err) {
if err := os.RemoveAll(dir); err != nil {
logrus.WithField("dir", dir).WithError(err).Error("Error removing dir.")
}
}

View file

@ -144,7 +144,7 @@ func (pm *Manager) HandleExitEvent(id string) error {
return err
}
if err := os.RemoveAll(filepath.Join(pm.config.ExecRoot, id)); err != nil && !os.IsNotExist(err) {
if err := os.RemoveAll(filepath.Join(pm.config.ExecRoot, id)); err != nil {
logrus.WithError(err).WithField("id", id).Error("Could not remove plugin bundle dir")
}

View file

@ -239,7 +239,7 @@ func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest, manifestDigest dige
defer func() {
if err != nil {
if rmErr := os.RemoveAll(orig); rmErr != nil && !os.IsNotExist(rmErr) {
if rmErr := os.RemoveAll(orig); rmErr != nil {
logrus.WithError(rmErr).WithField("dir", backup).Error("error cleaning up after failed upgrade")
return
}
@ -250,7 +250,7 @@ func (pm *Manager) upgradePlugin(p *v2.Plugin, configDigest, manifestDigest dige
logrus.WithError(rmErr).WithField("plugin", p.Name()).Errorf("error cleaning up plugin upgrade dir: %s", tmpRootFSDir)
}
} else {
if rmErr := os.RemoveAll(backup); rmErr != nil && !os.IsNotExist(rmErr) {
if rmErr := os.RemoveAll(backup); rmErr != nil {
logrus.WithError(rmErr).WithField("dir", backup).Error("error cleaning up old plugin root after successful upgrade")
}