@@ -19,7 +19,7 @@ import (
1919 "github.com/lima-vm/go-qcow2reader"
2020 "github.com/sirupsen/logrus"
2121
22- "github.com/lima-vm/lima/v2/pkg/downloader "
22+ "github.com/lima-vm/lima/v2/pkg/cacheutil "
2323 "github.com/lima-vm/lima/v2/pkg/driver"
2424 "github.com/lima-vm/lima/v2/pkg/driverutil"
2525 "github.com/lima-vm/lima/v2/pkg/executil"
@@ -37,41 +37,6 @@ import (
3737// to be running before timing out.
3838const DefaultWatchHostAgentEventsTimeout = 10 * time .Minute
3939
40- // ensureNerdctlArchiveCache prefetches the nerdctl-full-VERSION-GOOS-GOARCH.tar.gz archive
41- // into the cache before launching the hostagent process, so that we can show the progress in tty.
42- // https://github.com/lima-vm/lima/issues/326
43- func ensureNerdctlArchiveCache (ctx context.Context , y * limatype.LimaYAML , created bool ) (string , error ) {
44- if ! * y .Containerd .System && ! * y .Containerd .User {
45- // nerdctl archive is not needed
46- return "" , nil
47- }
48-
49- errs := make ([]error , len (y .Containerd .Archives ))
50- for i , f := range y .Containerd .Archives {
51- // Skip downloading again if the file is already in the cache
52- if created && f .Arch == * y .Arch && ! downloader .IsLocal (f .Location ) {
53- path , err := fileutils .CachedFile (f )
54- if err == nil {
55- return path , nil
56- }
57- }
58- path , err := fileutils .DownloadFile (ctx , "" , f , false , "the nerdctl archive" , * y .Arch )
59- if err != nil {
60- errs [i ] = err
61- continue
62- }
63- if path == "" {
64- if downloader .IsLocal (f .Location ) {
65- return f .Location , nil
66- }
67- return "" , fmt .Errorf ("cache did not contain %q" , f .Location )
68- }
69- return path , nil
70- }
71-
72- return "" , fileutils .Errors (errs )
73- }
74-
7540type Prepared struct {
7641 Driver driver.Driver
7742 GuestAgent string
@@ -154,7 +119,7 @@ func Prepare(ctx context.Context, inst *limatype.Instance) (*Prepared, error) {
154119 return nil , err
155120 }
156121
157- nerdctlArchiveCache , err := ensureNerdctlArchiveCache (ctx , inst .Config , created )
122+ nerdctlArchiveCache , err := cacheutil . EnsureNerdctlArchiveCache (ctx , inst .Config , created )
158123 if err != nil {
159124 return nil , err
160125 }
0 commit comments