@@ -10,7 +10,6 @@ import (
1010 "encoding/json"
1111 "errors"
1212 "io/ioutil"
13- "net/http"
1413 "os"
1514 "os/exec"
1615 "path/filepath"
@@ -390,13 +389,28 @@ func (rs *remoteContentStorage) Download(ctx context.Context, destination string
390389 }
391390
392391 span .SetTag ("URL" , info .URL )
393- resp , err := http .Get (info .URL )
392+
393+ tempFile , err := os .CreateTemp ("" , "remote-content-" )
394+ if err != nil {
395+ return true , xerrors .Errorf ("cannot create temporal file: %w" , err )
396+ }
397+ defer tempFile .Close ()
398+ defer os .Remove (tempFile .Name ())
399+
400+ args := []string {
401+ "-x16" , "-j12" ,
402+ info .URL ,
403+ "-o" , tempFile .Name (),
404+ }
405+ cmd := exec .Command ("aria2c" , args ... )
406+ var out []byte
407+ out , err = cmd .CombinedOutput ()
394408 if err != nil {
395- return true , err
409+ log .WithError (err ).WithField ("out" , string (out )).Error ("unexpected error downloading file" )
410+ return true , xerrors .Errorf ("unexpected error downloading file" )
396411 }
397- defer resp .Body .Close ()
398412
399- err = archive .ExtractTarbal (ctx , resp . Body , destination , archive .WithUIDMapping (mappings ), archive .WithGIDMapping (mappings ))
413+ err = archive .ExtractTarbal (ctx , tempFile , destination , archive .WithUIDMapping (mappings ), archive .WithGIDMapping (mappings ))
400414 if err != nil {
401415 return true , xerrors .Errorf ("tar %s: %s" , destination , err .Error ())
402416 }
0 commit comments