Potential fix for ADD .

Docker-DCO-1.0-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
Frank Macreery 2014-01-06 22:42:57 -05:00 committed by Guillaume J. Charmes
parent c6350bcc24
commit 93ff70a3e7
No known key found for this signature in database
GPG Key ID: B33E4642CB6E3FF3
2 changed files with 23 additions and 1 deletions

View File

@ -421,7 +421,9 @@ func (b *buildFile) CmdAdd(args string) error {
} else if fi.IsDir() { } else if fi.IsDir() {
var subfiles []string var subfiles []string
for file, sum := range sums { for file, sum := range sums {
if strings.HasPrefix(file, origPath) { absFile := path.Join(b.contextPath, file)
absOrigPath := path.Join(b.contextPath, origPath)
if strings.HasPrefix(absFile, absOrigPath) {
subfiles = append(subfiles, sum) subfiles = append(subfiles, sum)
} }
} }

View File

@ -592,6 +592,26 @@ func TestBuildADDLocalFileWithoutCache(t *testing.T) {
checkCacheBehavior(t, template, false) checkCacheBehavior(t, template, false)
} }
func TestBuildADDCurrentDirectoryWithCache(t *testing.T) {
template := testContextTemplate{`
from {IMAGE}
maintainer dockerio
add . /usr/lib/bla
`,
nil, nil}
checkCacheBehavior(t, template, true)
}
func TestBuildADDCurrentDirectoryWithoutCache(t *testing.T) {
template := testContextTemplate{`
from {IMAGE}
maintainer dockerio
add . /usr/lib/bla
`,
nil, nil}
checkCacheBehavior(t, template, false)
}
func TestBuildADDRemoteFileWithCache(t *testing.T) { func TestBuildADDRemoteFileWithCache(t *testing.T) {
template := testContextTemplate{` template := testContextTemplate{`
from {IMAGE} from {IMAGE}