resources: file: Do not error on os.Stat in noop mode

Fix #142.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
Julien Pivotto
2017-02-14 20:45:44 +01:00
parent 0e069f1e75
commit 605688426d

View File

@@ -676,6 +676,13 @@ func (obj *FileRes) chmodCheckApply(apply bool) (checkOK bool, _ error) {
} }
mode, err := obj.mode() mode, err := obj.mode()
// If the file does not exist and we are in
// noop mode, do not throw an error.
if os.IsNotExist(err) && !apply {
return false, nil
}
if err != nil { if err != nil {
return false, err return false, err
} }
@@ -710,6 +717,13 @@ func (obj *FileRes) chownCheckApply(apply bool) (checkOK bool, _ error) {
} }
st, err := os.Stat(obj.Path) st, err := os.Stat(obj.Path)
// If the file does not exist and we are in
// noop mode, do not throw an error.
if os.IsNotExist(err) && !apply {
return false, nil
}
if err != nil { if err != nil {
return false, err return false, err
} }