From 315260203c3a683fe7e93aa6c937128d38d52ae4 Mon Sep 17 00:00:00 2001 From: Shishir Mahajan Date: Fri, 16 Jan 2015 19:38:11 -0500 Subject: [PATCH] Implementation of docker load command: Untarr the incoming tar stream directly into /var/lib/docker/tmp without creating the tar ball Signed-off-by: Shishir Mahajan --- graph/load.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/graph/load.go b/graph/load.go index 4399da25d9..8f1da31136 100644 --- a/graph/load.go +++ b/graph/load.go @@ -4,7 +4,6 @@ package graph import ( "encoding/json" - "io" "io/ioutil" "os" "path" @@ -27,23 +26,9 @@ func (s *TagStore) CmdLoad(job *engine.Job) engine.Status { defer os.RemoveAll(tmpImageDir) var ( - repoTarFile = path.Join(tmpImageDir, "repo.tar") - repoDir = path.Join(tmpImageDir, "repo") + repoDir = path.Join(tmpImageDir, "repo") ) - tarFile, err := os.Create(repoTarFile) - if err != nil { - return job.Error(err) - } - if _, err := io.Copy(tarFile, job.Stdin); err != nil { - return job.Error(err) - } - tarFile.Close() - - repoFile, err := os.Open(repoTarFile) - if err != nil { - return job.Error(err) - } if err := os.Mkdir(repoDir, os.ModeDir); err != nil { return job.Error(err) } @@ -57,7 +42,7 @@ func (s *TagStore) CmdLoad(job *engine.Job) engine.Status { excludes[i] = k i++ } - if err := chrootarchive.Untar(repoFile, repoDir, &archive.TarOptions{ExcludePatterns: excludes}); err != nil { + if err := chrootarchive.Untar(job.Stdin, repoDir, &archive.TarOptions{ExcludePatterns: excludes}); err != nil { return job.Error(err) }