|
4 | 4 | "context"
|
5 | 5 | "errors"
|
6 | 6 | "fmt"
|
| 7 | + "io/fs" |
7 | 8 | "os"
|
8 | 9 | "strings"
|
9 | 10 |
|
@@ -171,18 +172,24 @@ func createOCIRef(sys *types.SystemContext, image string) (tempDirOCIRef, error)
|
171 | 172 |
|
172 | 173 | // creates the temporary directory and copies the tarred content to it
|
173 | 174 | func createUntarTempDir(sys *types.SystemContext, ref ociArchiveReference) (tempDirOCIRef, error) {
|
174 |
| - tempDirRef, err := createOCIRef(sys, ref.image) |
175 |
| - if err != nil { |
176 |
| - return tempDirOCIRef{}, fmt.Errorf("creating oci reference: %w", err) |
177 |
| - } |
178 | 175 | src := ref.resolvedFile
|
179 |
| - dst := tempDirRef.tempDirectory |
180 | 176 | // TODO: This can take quite some time, and should ideally be cancellable using a context.Context.
|
181 | 177 | arch, err := os.Open(src)
|
182 | 178 | if err != nil {
|
183 |
| - return tempDirOCIRef{}, err |
| 179 | + if errors.Is(err, fs.ErrNotExist) { |
| 180 | + return tempDirOCIRef{}, ImageNotFoundError{ref: ref} |
| 181 | + } else { |
| 182 | + return tempDirOCIRef{}, err |
| 183 | + } |
184 | 184 | }
|
185 | 185 | defer arch.Close()
|
| 186 | + |
| 187 | + tempDirRef, err := createOCIRef(sys, ref.image) |
| 188 | + if err != nil { |
| 189 | + return tempDirOCIRef{}, fmt.Errorf("creating oci reference: %w", err) |
| 190 | + } |
| 191 | + dst := tempDirRef.tempDirectory |
| 192 | + |
186 | 193 | if err := archive.NewDefaultArchiver().Untar(arch, dst, &archive.TarOptions{NoLchown: true}); err != nil {
|
187 | 194 | if err := tempDirRef.deleteTempDir(); err != nil {
|
188 | 195 | return tempDirOCIRef{}, fmt.Errorf("deleting temp directory %q: %w", tempDirRef.tempDirectory, err)
|
|
0 commit comments