Properly report the ID of newly added keys

Other commands like key list and key remove show the key's ID.

Showing the ID here lets users easily reuse the ID as a key hint for subsequent
commands.
In particular, a key hint is needed when the repository has many keys - otherwise
opening the repository may fail with "Fatal: maximum number of keys reached" even
when a proper password is provided.

Fixes #4656
This commit is contained in:
Lionel Sausin 2024-01-25 10:12:11 +01:00
parent 446167ae80
commit 8fbe328371
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,7 @@
Bugfix: Properly report the ID of newly added keys
`restic key add` now reports the ID of a newly added key. This simplifies
selecting a specific key using the `--key-hint key` option.
https://github.com/restic/restic/issues/4656
https://github.com/restic/restic/pull/4657

View File

@ -142,7 +142,7 @@ func addKey(ctx context.Context, repo *repository.Repository, gopts GlobalOption
return err
}
Verbosef("saved new key as %s\n", id)
Verbosef("saved new key with ID %s\n", id.ID())
return nil
}