Skip to content

Commit afda503

Browse files
committed
Move up vm cache dir creation logic
Currently, the vm cache logic is all over the place making it difficult to implement locks. Although this requires a refactoring, let's move the creation of the cache directory one level up, to allow for more locks granularity. Signed-off-by: German Maglione <[email protected]>
1 parent 7105a78 commit afda503

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/bootc/bootc_disk.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ func (p *BootcDisk) Install(quiet bool) (err error) {
103103
return
104104
}
105105

106+
// Create VM cache dir; one per oci bootc image
107+
p.Directory = filepath.Join(p.User.CacheDir(), p.ImageId)
108+
if err := os.MkdirAll(p.Directory, os.ModePerm); err != nil {
109+
return fmt.Errorf("error while making bootc disk directory: %w", err)
110+
}
111+
106112
err = p.getOrInstallImageToDisk(quiet)
107113
if err != nil {
108114
return
@@ -246,12 +252,6 @@ func (p *BootcDisk) pullImage() (err error) {
246252
p.ImageId = imageId
247253
p.RepoTag = image.RepoTags[0]
248254

249-
// Create VM cache dir; one per oci bootc image
250-
p.Directory = filepath.Join(p.User.CacheDir(), imageId)
251-
if err := os.MkdirAll(p.Directory, os.ModePerm); err != nil {
252-
return fmt.Errorf("error while making bootc disk directory: %w", err)
253-
}
254-
255255
return
256256
}
257257

0 commit comments

Comments
 (0)