0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-06-30 18:42:58 +00:00

fix(storage): ignore os.ErrClosed from deferred fileReader.Close() in storage.APIUpload (#1468)

fix(provider): ignore `ErrClosed` for fileReader

Signed-off-by: Keith King <KingKeithC@gmail.com>
This commit is contained in:
Keith 2024-08-06 20:36:24 -06:00 committed by GitHub
parent f7c3560260
commit e8bd1fcda7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@ package storage
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"mime/multipart" "mime/multipart"
@ -112,6 +113,11 @@ func (c *Client) APIUpload(
defer func(fileReader *os.File) { defer func(fileReader *os.File) {
e := fileReader.Close() e := fileReader.Close()
if e != nil { if e != nil {
if errors.Is(e, os.ErrClosed) {
// We can ignore the error in the case that the file was already closed.
return
}
tflog.Error(ctx, "failed to close file reader", map[string]interface{}{ tflog.Error(ctx, "failed to close file reader", map[string]interface{}{
"error": e, "error": e,
}) })