mirror of https://github.com/docker/docs.git
Make sure the remote ADD are cached properly
Docker-DCO-1.0-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
parent
762a0cc472
commit
0fd9c98de3
14
buildfile.go
14
buildfile.go
|
@ -355,6 +355,7 @@ func (b *buildFile) CmdAdd(args string) error {
|
||||||
var (
|
var (
|
||||||
origPath = orig
|
origPath = orig
|
||||||
destPath = dest
|
destPath = dest
|
||||||
|
remoteHash string
|
||||||
)
|
)
|
||||||
|
|
||||||
if utils.IsURL(orig) {
|
if utils.IsURL(orig) {
|
||||||
|
@ -373,11 +374,20 @@ func (b *buildFile) CmdAdd(args string) error {
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpDirName)
|
defer os.RemoveAll(tmpDirName)
|
||||||
if _, err = io.Copy(tmpFile, resp.Body); err != nil {
|
if _, err = io.Copy(tmpFile, resp.Body); err != nil {
|
||||||
|
tmpFile.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
origPath = path.Join(filepath.Base(tmpDirName), filepath.Base(tmpFileName))
|
origPath = path.Join(filepath.Base(tmpDirName), filepath.Base(tmpFileName))
|
||||||
tmpFile.Close()
|
tmpFile.Close()
|
||||||
|
|
||||||
|
// Process the checksum
|
||||||
|
r, err := archive.Tar(tmpFileName, archive.Uncompressed)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tarSum := utils.TarSum{Reader: r, DisableCompression: true}
|
||||||
|
remoteHash = tarSum.Sum(nil)
|
||||||
|
|
||||||
// If the destination is a directory, figure out the filename.
|
// If the destination is a directory, figure out the filename.
|
||||||
if strings.HasSuffix(dest, "/") {
|
if strings.HasSuffix(dest, "/") {
|
||||||
u, err := url.Parse(orig)
|
u, err := url.Parse(orig)
|
||||||
|
@ -408,7 +418,9 @@ func (b *buildFile) CmdAdd(args string) error {
|
||||||
sums = b.context.GetSums()
|
sums = b.context.GetSums()
|
||||||
)
|
)
|
||||||
|
|
||||||
if fi, err := os.Stat(path.Join(b.contextPath, origPath)); err != nil {
|
if remoteHash != "" {
|
||||||
|
hash = remoteHash
|
||||||
|
} else if fi, err := os.Stat(path.Join(b.contextPath, origPath)); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if fi.IsDir() {
|
} else if fi.IsDir() {
|
||||||
var subfiles []string
|
var subfiles []string
|
||||||
|
|
Loading…
Reference in New Issue