migrate: show warning if migration is unknown

This commit is contained in:
Michael Eischer 2024-08-03 17:22:56 +02:00
parent 8d5e188218
commit db77919550

View file

@ -74,8 +74,10 @@ func checkMigrations(ctx context.Context, repo restic.Repository, printer progre
func applyMigrations(ctx context.Context, opts MigrateOptions, gopts GlobalOptions, repo restic.Repository, args []string, term *termstatus.Terminal, printer progress.Printer) error { func applyMigrations(ctx context.Context, opts MigrateOptions, gopts GlobalOptions, repo restic.Repository, args []string, term *termstatus.Terminal, printer progress.Printer) error {
var firsterr error var firsterr error
for _, name := range args { for _, name := range args {
found := false
for _, m := range migrations.All { for _, m := range migrations.All {
if m.Name() == name { if m.Name() == name {
found = true
ok, reason, err := m.Check(ctx, repo) ok, reason, err := m.Check(ctx, repo)
if err != nil { if err != nil {
return err return err
@ -119,6 +121,9 @@ func applyMigrations(ctx context.Context, opts MigrateOptions, gopts GlobalOptio
printer.P("migration %v: success\n", m.Name()) printer.P("migration %v: success\n", m.Name())
} }
} }
if !found {
printer.E("unknown migration %v", name)
}
} }
return firsterr return firsterr