summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2018-04-27 16:28:19 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-11 16:26:35 +0000
commit5676597f40b61a71704b7f509bd71053d936eaa9 (patch)
treec974dceafcd6bdd0e31e4ad3da9d8a0773541aec
parent68eb128fb0ad261f48f960547742542584ff1f11 (diff)
downloadpodman-5676597f40b61a71704b7f509bd71053d936eaa9.tar.gz
podman-5676597f40b61a71704b7f509bd71053d936eaa9.tar.bz2
podman-5676597f40b61a71704b7f509bd71053d936eaa9.zip
hooks/read: Ignore IsNotExist for JSON files in ReadDir
If a .json file existed when we called ioutil.ReadDir but that file has been removed by the time we get around to calling Read on it, silently ignore the file. Iterating through all the files in the directory shouldn't take particularly long, so this is an unlikely corner case. And when it happens, silently ignoring the file gives the same outcome as you'd have gotten if the parallel remove had happened slightly earlier before the ioutil.ReadDir call. Signed-off-by: W. Trevor King <wking@tremily.us> Closes: #686 Approved by: mheon
-rw-r--r--pkg/hooks/read.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/hooks/read.go b/pkg/hooks/read.go
index fab37351b..29953ac5d 100644
--- a/pkg/hooks/read.go
+++ b/pkg/hooks/read.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
+ "os"
"path/filepath"
"strings"
@@ -71,6 +72,9 @@ func ReadDir(path string, hooks map[string]*current.Hook) error {
if err == ErrNoJSONSuffix {
continue
}
+ if os.IsNotExist(err) {
+ continue
+ }
return err
}
hooks[file.Name()] = hook