Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small cleanup #580

Merged
merged 2 commits into from
Dec 12, 2024
Merged
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
12 changes: 7 additions & 5 deletions cmds/genimgs/genimgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"sort"
"strings"
"sync"
"time"

awsconfig "github.com/aws/aws-sdk-go-v2/config"
s3manager "github.com/aws/aws-sdk-go-v2/feature/s3/manager"
Expand Down Expand Up @@ -466,6 +467,9 @@ func createImage(img generateImage) error {
}

func (c *client) uploadImage(ctx context.Context, img generateImage) error {
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()

f, err := os.Open(img.outputPath)
if err != nil {
return err
Expand Down Expand Up @@ -513,19 +517,17 @@ func createWebpImage(img generateImage) error {
if err != nil {
return err
}
defer f.Close()

err = webp.Encode(f, dst, nil)
if err != nil {
return err
}
return nil
return webp.Encode(f, dst, nil)
}

func createAvifImage(img generateImage) error {
tmpDir, err := ioutil.TempDir("", "")
if err != nil {
return err
}
defer os.RemoveAll(tmpDir) // Clean up temporary directory

origExt := path.Ext(img.originalPath)
outputExt := path.Ext(img.outputPath)
Expand Down
Loading