@@ -30,7 +30,7 @@ func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes
3030
3131 tempImagePath , err := DownloadAndExtract (client , version , func (target string ) (bool , error ) {
3232 feedback .Printf ("Found Debian image version: %s" , target )
33- feedback .Printf ("Do you want to download it and flash it on the board ? (yes/no)" )
33+ feedback .Printf ("Do you want to download it? (yes/no)" )
3434
3535 var yesInput string
3636 _ , err := fmt .Scanf ("%s\n " , & yesInput )
@@ -73,10 +73,32 @@ func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes
7373 imagePath = tempContent [0 ]
7474 }
7575
76- return FlashBoard (ctx , imagePath .String ())
76+ return FlashBoard (ctx , imagePath .String (), func (target string ) (bool , error ) {
77+ feedback .Print ("\n WARNING: flashing a new Linux image on the board will erase any existing data you have on it." )
78+ feedback .Printf ("Do you want to procede and flash %s on the board? (yes/no)" , target )
79+
80+ var yesInput string
81+ _ , err := fmt .Scanf ("%s\n " , & yesInput )
82+ if err != nil {
83+ return false , err
84+ }
85+ yes := strings .ToLower (yesInput ) == "yes" || strings .ToLower (yesInput ) == "y"
86+ return yes , nil
87+ }, forceYes )
7788}
7889
79- func FlashBoard (ctx context.Context , downloadedImagePath string ) error {
90+ func FlashBoard (ctx context.Context , downloadedImagePath string , upgradeConfirmCb DownloadConfirmCB , forceYes bool ) error {
91+ if ! forceYes {
92+ res , err := upgradeConfirmCb (downloadedImagePath )
93+ if err != nil {
94+ return err
95+ }
96+ if ! res {
97+ feedback .Print (i18n .Tr ("Flashing not confirmed by user, exiting" ))
98+ return nil
99+ }
100+ }
101+
80102 qdl , err := getQdlBytes ()
81103 if err != nil {
82104 return err
0 commit comments