From 79f4b1d43264e9c9f1c18bd1d4824a8536b299ab Mon Sep 17 00:00:00 2001 From: Martin Mulholland Date: Wed, 10 Feb 2021 17:02:54 -0500 Subject: [PATCH] Modify tmp dir logic --- tests/v2/utils/test_utils.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/v2/utils/test_utils.go b/tests/v2/utils/test_utils.go index fa1b26be..bcd04654 100644 --- a/tests/v2/utils/test_utils.go +++ b/tests/v2/utils/test_utils.go @@ -67,13 +67,11 @@ func init() { // Returns the name of the created directory. func CreateTempDir(subdir string) string { tempDir := tmpDir + subdir + "/" - if _, err := os.Stat(tempDir); os.IsNotExist(err) { - if err = os.Mkdir(tempDir, 0755); err != nil { - LogErrorMessage(fmt.Sprintf("Failed to create temp directory %s will use %s : %v", tempDir, tmpDir, err)) - // if cannot create subdirectory just use the base tmp directory - tempDir = tmpDir - } - } else if err != nil { + var err error + if _, err = os.Stat(tempDir); os.IsNotExist(err) { + err = os.Mkdir(tempDir, 0755) + } + if err != nil { // if cannot create subdirectory just use the base tmp directory LogErrorMessage(fmt.Sprintf("Failed to create temp directory %s will use %s : %v", tempDir, tmpDir, err)) tempDir = tmpDir