@@ -161,8 +161,21 @@ func (handlers *Handlers) postSetPassword(r *http.Request) (interface{}, error)
161161}
162162
163163func (handlers * Handlers ) postCreateBackup (r * http.Request ) (interface {}, error ) {
164- if err := handlers .device .CreateBackup (); err != nil {
165- return maybeBB02Err (err , handlers .log ), nil
164+ var backupMethod string
165+ if err := json .NewDecoder (r .Body ).Decode (& backupMethod ); err != nil {
166+ return nil , errp .WithStack (err )
167+ }
168+ switch backupMethod {
169+ case "sdcard" :
170+ if err := handlers .device .CreateBackup (); err != nil {
171+ return maybeBB02Err (err , handlers .log ), nil
172+ }
173+ case "recovery-words" :
174+ if err := handlers .device .ShowMnemonic (); err != nil {
175+ return maybeBB02Err (err , handlers .log ), nil
176+ }
177+ default :
178+ return map [string ]interface {}{"success" : false }, nil
166179 }
167180 return map [string ]interface {}{"success" : true }, nil
168181}
@@ -284,11 +297,20 @@ func (handlers *Handlers) getVersionHandler(_ *http.Request) (interface{}, error
284297 NewVersion string `json:"newVersion"`
285298 CanUpgrade bool `json:"canUpgrade"`
286299 CanGotoStartupSettings bool `json:"canGotoStartupSettings"`
300+ // If true, creating a backup using the mnemonic recovery words instead of the microSD card
301+ // is supported in the initial setup.
302+ //
303+ // If false, the backup must be performed using the microSD card in the initial setup.
304+ //
305+ // This has no influence over whether one can display the recovery words after the initial
306+ // setup - that is always possible regardless of this value.
307+ CanBackupWithRecoveryWords bool `json:"canBackupWithRecoveryWords"`
287308 }{
288- CurrentVersion : currentVersion .String (),
289- NewVersion : newVersion .String (),
290- CanUpgrade : newVersion .AtLeast (currentVersion ) && currentVersion .String () != newVersion .String (),
291- CanGotoStartupSettings : currentVersion .AtLeast (semver .NewSemVer (9 , 6 , 0 )),
309+ CurrentVersion : currentVersion .String (),
310+ NewVersion : newVersion .String (),
311+ CanUpgrade : newVersion .AtLeast (currentVersion ) && currentVersion .String () != newVersion .String (),
312+ CanGotoStartupSettings : currentVersion .AtLeast (semver .NewSemVer (9 , 6 , 0 )),
313+ CanBackupWithRecoveryWords : currentVersion .AtLeast (semver .NewSemVer (9 , 13 , 0 )),
292314 }, nil
293315}
294316
0 commit comments