Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libpod/container_internal_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error {
if err != nil {
return fmt.Errorf("creating %q: %w", volumeTarFileFullPath, err)
}
defer volumeTarFile.Close()

volume, err := c.runtime.GetVolume(v.Name)
if err != nil {
Expand All @@ -1223,7 +1224,6 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error {
if err != nil {
return err
}
volumeTarFile.Close()

includeFiles = append(includeFiles, volumeTarFilePath)
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/bindings/containers/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ func Restore(ctx context.Context, nameOrID string, options *RestoreOptions) (*ty
}
if i != "" {
params.Set("import", "true")
r, err = os.Open(i)
f, err := os.Open(i)
if err != nil {
return nil, err
}
defer f.Close()
r = f
// Hard-code the name since it will be ignored in any case.
nameOrID = "import"
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/domain/infra/tunnel/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func (ir *ImageEngine) Import(_ context.Context, opts entities.ImageImportOption
if err != nil {
return nil, err
}
defer f.Close()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

samsies, wouldnt a single defer be better?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already a single defer. No changes needed here.

}
return images.Import(ir.ClientCtx, f, options)
}
Expand Down Expand Up @@ -354,6 +355,7 @@ func (ir *ImageEngine) Save(_ context.Context, nameOrID string, tags []string, o
if err != nil {
return err
}
defer f.Close()
info, err := os.Stat(opts.Output)
switch {
case err == nil:
Expand Down
Loading