Skip to content

Commit

Permalink
Set BigFilesTemporaryDir to GetEnv(TMPDIR) if set or /var/tmp
Browse files Browse the repository at this point in the history
Currently if the caller does not specify the BigFilesTemporaryDir,
Podman and Buildah users expect this to default TMPDIR environment
variable or /var/tmp if not set.

Moving to libimage caused a regression in this functionality.

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Jun 16, 2021
1 parent f10e62c commit aaebc06
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libimage/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// tmpdir returns a path to a temporary directory.
func (r *Runtime) tmpdir() string {
func tmpdir() string {
tmpdir := os.Getenv("TMPDIR")
if tmpdir == "" {
tmpdir = "/var/tmp"
Expand All @@ -25,7 +25,7 @@ func (r *Runtime) tmpdir() string {
func (r *Runtime) downloadFromURL(source string) (string, error) {
fmt.Printf("Downloading from %q\n", source)

outFile, err := ioutil.TempFile(r.tmpdir(), "import")
outFile, err := ioutil.TempFile(r.systemContext.BigFilesTemporaryDir, "import")
if err != nil {
return "", errors.Wrap(err, "error creating file")
}
Expand Down
3 changes: 3 additions & 0 deletions libimage/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func RuntimeFromStore(store storage.Store, options *RuntimeOptions) (*Runtime, e
} else {
systemContext = types.SystemContext{}
}
if systemContext.BigFilesTemporaryDir == "" {
systemContext.BigFilesTemporaryDir = tmpdir()
}

setRegistriesConfPath(&systemContext)

Expand Down
1 change: 1 addition & 0 deletions libimage/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func testNewRuntime(t *testing.T) (runtime *Runtime, cleanup func()) {

runtime, err = RuntimeFromStoreOptions(&RuntimeOptions{SystemContext: systemContext}, storeOptions)
require.NoError(t, err)
require.Equal(t, runtime.systemContext.BigFilesTemporaryDir, tmpdir())

cleanup = func() {
runtime.Shutdown(true)
Expand Down

0 comments on commit aaebc06

Please sign in to comment.