refactor: remove global temporary directory base
This commit is contained in:
parent
5ada1ef41a
commit
7cf1bbd194
4
debug.go
4
debug.go
@ -7,7 +7,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -16,6 +15,7 @@ import (
|
|||||||
"gopkg.in/logrusorgru/aurora.v2"
|
"gopkg.in/logrusorgru/aurora.v2"
|
||||||
|
|
||||||
"code.dumpstack.io/tools/out-of-tree/config"
|
"code.dumpstack.io/tools/out-of-tree/config"
|
||||||
|
"code.dumpstack.io/tools/out-of-tree/fs"
|
||||||
"code.dumpstack.io/tools/out-of-tree/qemu"
|
"code.dumpstack.io/tools/out-of-tree/qemu"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) {
|
|||||||
}
|
}
|
||||||
defer q.Stop()
|
defer q.Stop()
|
||||||
|
|
||||||
tmp, err := ioutil.TempDir(tempDirBase, "out-of-tree_")
|
tmp, err := fs.TempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
5
main.go
5
main.go
@ -99,8 +99,6 @@ func (lw *LevelWriter) WriteLevel(l zerolog.Level, p []byte) (n int, err error)
|
|||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var tempDirBase string
|
|
||||||
|
|
||||||
var consoleWriter, fileWriter LevelWriter
|
var consoleWriter, fileWriter LevelWriter
|
||||||
|
|
||||||
var loglevel zerolog.Level
|
var loglevel zerolog.Level
|
||||||
@ -139,9 +137,6 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tempDirBase = usr.HomeDir + "/.out-of-tree/tmp/"
|
|
||||||
os.MkdirAll(tempDirBase, os.ModePerm)
|
|
||||||
|
|
||||||
consoleWriter = LevelWriter{Writer: zerolog.NewConsoleWriter(
|
consoleWriter = LevelWriter{Writer: zerolog.NewConsoleWriter(
|
||||||
func(w *zerolog.ConsoleWriter) {
|
func(w *zerolog.ConsoleWriter) {
|
||||||
w.Out = os.Stderr
|
w.Out = os.Stderr
|
||||||
|
2
pew.go
2
pew.go
@ -659,7 +659,7 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
tmp, err := ioutil.TempDir(tempDirBase, "out-of-tree_")
|
tmp, err := fs.TempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error().Err(err).Msg("making tmp directory")
|
slog.Error().Err(err).Msg("making tmp directory")
|
||||||
return
|
return
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -62,7 +61,7 @@ func preload(q *qemu.System, ki config.KernelInfo, pm config.PreloadModule,
|
|||||||
func buildAndInsmod(workPath string, q *qemu.System, ki config.KernelInfo,
|
func buildAndInsmod(workPath string, q *qemu.System, ki config.KernelInfo,
|
||||||
dockerTimeout time.Duration, cache string) (err error) {
|
dockerTimeout time.Duration, cache string) (err error) {
|
||||||
|
|
||||||
tmp, err := ioutil.TempDir(tempDirBase, "out-of-tree_")
|
tmp, err := fs.TempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user