Skip to content

Commit

Permalink
Small cleanup (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
gauntface authored Dec 12, 2024
1 parent 57f27b0 commit a8c17d1
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit a8c17d1

Please sign in to comment.