Skip to content

Commit

Permalink
fix timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
vintikzzz committed Oct 6, 2024
1 parent 6e68f43 commit 51c816c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions handlers/job/script/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s *LoadScript) Run(j *job.Job) (err error) {

func (s *LoadScript) storeFile(j *job.Job, file []byte) (res *ra.ResourceResponse, err error) {
j.InProgress("uploading file")
ctx, cancel := context.WithTimeout(j.Context, 10*time.Second)
ctx, cancel := context.WithTimeout(j.Context, 60*time.Second)
defer cancel()
res, err = s.api.StoreResource(ctx, s.claims, file)
if err != nil {
Expand All @@ -73,7 +73,7 @@ func (s *LoadScript) storeQuery(j *job.Job, query string) (res *ra.ResourceRespo
if !strings.HasPrefix(query, "magnet:") {
query = "magnet:?xt=urn:btih:" + hash
}
ctx, cancel := context.WithTimeout(j.Context, 10*time.Second)
ctx, cancel := context.WithTimeout(j.Context, 60*time.Second)
defer cancel()
res, err = s.api.GetResource(ctx, s.claims, hash)
if err != nil {
Expand All @@ -86,11 +86,11 @@ func (s *LoadScript) storeQuery(j *job.Job, query string) (res *ra.ResourceRespo
j.Done()
j.Info("sadly, we don't have torrent, so we have to magnetize it from peers")
j.InProgress("magnetizing")
ctx, cancel = context.WithTimeout(j.Context, 30*time.Second)
ctx, cancel = context.WithTimeout(j.Context, 60*time.Second)
defer cancel()
res, err = s.api.StoreResource(ctx, s.claims, []byte(query))
if err != nil || res == nil {
return nil, j.Error(err, "failed to magnetize, there were no peers for 30 seconds, try another magnet")
return nil, j.Error(err, "failed to magnetize, there were no peers for 60 seconds, try another magnet")
}
j.Done()
return
Expand Down

0 comments on commit 51c816c

Please sign in to comment.