@@ -46,8 +46,8 @@ type Release struct {
4646// DownloadConfirmCB is a function that is called when a Debian image is ready to be downloaded.
4747type DownloadConfirmCB func (target string ) (bool , error )
4848
49- func DownloadAndExtract (client * Client , targetVersion string , upgradeConfirmCb DownloadConfirmCB , forceYes bool , temp * paths.Path ) (* paths.Path , string , error ) {
50- tmpZip , version , err := DownloadImage (client , targetVersion , upgradeConfirmCb , forceYes , temp )
49+ func DownloadAndExtract (ctx context. Context , client * Client , targetVersion string , upgradeConfirmCb DownloadConfirmCB , forceYes bool , temp * paths.Path ) (* paths.Path , string , error ) {
50+ tmpZip , version , err := DownloadImage (ctx , client , targetVersion , upgradeConfirmCb , forceYes , temp )
5151 if err != nil {
5252 return nil , "" , fmt .Errorf ("error downloading the image: %v" , err )
5353 }
@@ -57,7 +57,7 @@ func DownloadAndExtract(client *Client, targetVersion string, upgradeConfirmCb D
5757 return nil , "" , nil
5858 }
5959
60- err = ExtractImage (tmpZip , tmpZip .Parent ())
60+ err = ExtractImage (ctx , tmpZip , tmpZip .Parent ())
6161 if err != nil {
6262 return nil , "" , fmt .Errorf ("error extracting the image: %v" , err )
6363 }
@@ -69,11 +69,11 @@ func DownloadAndExtract(client *Client, targetVersion string, upgradeConfirmCb D
6969 return imagePath , version , nil
7070}
7171
72- func DownloadImage (client * Client , targetVersion string , upgradeConfirmCb DownloadConfirmCB , forceYes bool , downloadPath * paths.Path ) (* paths.Path , string , error ) {
72+ func DownloadImage (ctx context. Context , client * Client , targetVersion string , upgradeConfirmCb DownloadConfirmCB , forceYes bool , downloadPath * paths.Path ) (* paths.Path , string , error ) {
7373 var err error
7474
7575 feedback .Print (i18n .Tr ("Checking for Debian image releases" ))
76- manifest , err := client .GetInfoManifest ()
76+ manifest , err := client .GetInfoManifest (ctx )
7777 if err != nil {
7878 return nil , "" , err
7979 }
@@ -105,7 +105,7 @@ func DownloadImage(client *Client, targetVersion string, upgradeConfirmCb Downlo
105105 }
106106 }
107107
108- download , size , err := client .FetchZip (rel .Url )
108+ download , size , err := client .FetchZip (ctx , rel .Url )
109109 if err != nil {
110110 return nil , "" , fmt .Errorf ("could not fetch Debian image: %w" , err )
111111 }
@@ -140,7 +140,7 @@ func DownloadImage(client *Client, targetVersion string, upgradeConfirmCb Downlo
140140 return tmpZip , rel .Version , nil
141141}
142142
143- func ExtractImage (archive , temp * paths.Path ) error {
143+ func ExtractImage (ctx context. Context , archive , temp * paths.Path ) error {
144144 // Unzip the Debian image
145145 feedback .Print (i18n .Tr ("Unzipping Debian image" ))
146146 tmpZipFile , err := archive .Open ()
@@ -149,7 +149,7 @@ func ExtractImage(archive, temp *paths.Path) error {
149149 }
150150 defer tmpZipFile .Close ()
151151
152- if err := extract .Archive (context . Background () , tmpZipFile , temp .String (), func (s string ) string {
152+ if err := extract .Archive (ctx , tmpZipFile , temp .String (), func (s string ) string {
153153 feedback .Print (s )
154154 return s
155155 }); err != nil {
0 commit comments