1
0
Fork 0

fix: load local archive

timestamps
dump_stack() 2024-02-21 22:52:38 +00:00
parent 8812cb4293
commit 335eeb5ed5
Signed by: dump_stack
GPG Key ID: C9905BA72B5E02BB
2 changed files with 19 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/cavaliergopher/grab/v3"
"github.com/naoina/toml" "github.com/naoina/toml"
"github.com/remeh/sizedwaitgroup" "github.com/remeh/sizedwaitgroup"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
@ -21,6 +22,7 @@ import (
"code.dumpstack.io/tools/out-of-tree/config/dotfiles" "code.dumpstack.io/tools/out-of-tree/config/dotfiles"
"code.dumpstack.io/tools/out-of-tree/container" "code.dumpstack.io/tools/out-of-tree/container"
"code.dumpstack.io/tools/out-of-tree/distro" "code.dumpstack.io/tools/out-of-tree/distro"
"code.dumpstack.io/tools/out-of-tree/fs"
"code.dumpstack.io/tools/out-of-tree/kernel" "code.dumpstack.io/tools/out-of-tree/kernel"
) )
@ -174,10 +176,22 @@ func (cmd *KernelCmd) fetchContainerCache(c container.Container) {
return return
} }
path := cache.ContainerURL(c.Name()) tmp, err := fs.TempDir()
err := container.Load(path, c.Name()) if err != nil {
return
}
defer os.RemoveAll(tmp)
resp, err := grab.Get(tmp, cache.ContainerURL(c.Name()))
if err != nil {
return
}
defer os.Remove(resp.Filename)
err = container.Load(resp.Filename, c.Name())
if err == nil { if err == nil {
log.Info().Msgf("container %s -> %s", path, c.Name()) log.Info().Msgf("use prebuilt container %s", c.Name())
} }
} }

View File

@ -77,13 +77,13 @@ func Images() (diis []Image, err error) {
return return
} }
func Load(path string, name string) (err error) { func Load(localpath string, name string) (err error) {
exist := Container{name: name}.Exist() exist := Container{name: name}.Exist()
if exist && UseCache { if exist && UseCache {
return return
} }
cmd := exec.Command(Runtime, "load", "-i", path) cmd := exec.Command(Runtime, "load", "-i", localpath)
log.Debug().Msgf("%v", cmd) log.Debug().Msgf("%v", cmd)
raw, err := cmd.CombinedOutput() raw, err := cmd.CombinedOutput()