1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix "foo: no such file or directory" test failure, and normalize creation of custom error to always depend on if os.IsNotExist(err) so we don't hide other errors that might crop up in these tests

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)

Docker-DCO-1.1-Signed-off-by: Tianon Gravi <admwiggin@gmail.com> (github: crosbymichael)
This commit is contained in:
Tianon Gravi 2014-01-14 11:42:03 -07:00 committed by Michael Crosby
parent ad69836247
commit 42fed841d3

View file

@ -288,6 +288,9 @@ func (b *buildFile) CmdVolume(args string) error {
func (b *buildFile) checkPathForAddition(orig string) error { func (b *buildFile) checkPathForAddition(orig string) error {
origPath := path.Join(b.contextPath, orig) origPath := path.Join(b.contextPath, orig)
if p, err := filepath.EvalSymlinks(origPath); err != nil { if p, err := filepath.EvalSymlinks(origPath); err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("%s: no such file or directory", orig)
}
return err return err
} else { } else {
origPath = p origPath = p
@ -297,8 +300,11 @@ func (b *buildFile) checkPathForAddition(orig string) error {
} }
_, err := os.Stat(origPath) _, err := os.Stat(origPath)
if err != nil { if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("%s: no such file or directory", orig) return fmt.Errorf("%s: no such file or directory", orig)
} }
return err
}
return nil return nil
} }
@ -313,8 +319,11 @@ func (b *buildFile) addContext(container *Container, orig, dest string) error {
} }
fi, err := os.Stat(origPath) fi, err := os.Stat(origPath)
if err != nil { if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("%s: no such file or directory", orig) return fmt.Errorf("%s: no such file or directory", orig)
} }
return err
}
if fi.IsDir() { if fi.IsDir() {
if err := archive.CopyWithTar(origPath, destPath); err != nil { if err := archive.CopyWithTar(origPath, destPath); err != nil {
return err return err