Skip to content

Commit

Permalink
Fix file descriptor leak
Browse files Browse the repository at this point in the history
Signed-off-by: David Son <[email protected]>
  • Loading branch information
sondavidb committed Jan 23, 2024
1 parent b81ba3b commit db7df3a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/unpacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,19 @@ func (lu *layerUnpacker) Unpack(ctx context.Context, desc ocispec.Descriptor, mo
if err != nil {
return fmt.Errorf("cannot fetch layer: %w", err)
}
defer rc.Close()

if !local {
if err = lu.fetcher.Store(ctx, desc, rc); err != nil {
err := lu.fetcher.Store(ctx, desc, rc)
rc.Close()
if err != nil {
return fmt.Errorf("cannot store layer: %w", err)
}
rc.Close()
rc, _, err = lu.fetcher.Fetch(ctx, desc)
if err != nil {
return fmt.Errorf("cannot fetch layer: %w", err)
}
}
defer rc.Close()
parents, err := getLayerParents(mounts[0].Options)
if err != nil {
return fmt.Errorf("cannot get layer parents: %w", err)
Expand Down

0 comments on commit db7df3a

Please sign in to comment.