Skip to content

Commit

Permalink
Add 30 second timeout to get image
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Mar 2, 2020
1 parent 9b256e6 commit 54dcdcf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/scraper/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ import (
"io/ioutil"
"net/http"
"strings"
"time"

"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/utils"
)

// Timeout to get the image. Includes transfer time. May want to make this
// configurable at some point.
const imageGetTimeout = time.Second * 30

func setPerformerImage(p *models.ScrapedPerformer) error {
if p == nil || p.Image == nil || !strings.HasPrefix(*p.Image, "http") {
// nothing to do
Expand Down Expand Up @@ -43,8 +48,12 @@ func setSceneImage(s *models.ScrapedScene) error {
}

func getImage(url string) (*string, error) {
client := &http.Client{
Timeout: imageGetTimeout,
}

// assume is a URL for now
resp, err := http.Get(url)
resp, err := client.Get(url)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 54dcdcf

Please sign in to comment.