Skip to content

Commit ab69696

Browse files
authored
fix getBackup panic if pass a invalid backup ID (#424)
Signed-off-by: wayblink <[email protected]>
1 parent 7aad2e6 commit ab69696

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

core/backup_context.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,13 @@ func (b *BackupContext) GetRestore(ctx context.Context, request *backuppb.GetRes
647647
}
648648

649649
task := b.meta.GetRestoreTask(request.GetId())
650-
progress := int32(float32(task.GetRestoredSize()) * 100 / float32(task.GetToRestoreSize()))
651-
// don't return zero
652-
if progress == 0 {
653-
progress = 1
654-
}
655-
task.Progress = progress
656650
if task != nil {
651+
progress := int32(float32(task.GetRestoredSize()) * 100 / float32(task.GetToRestoreSize()))
652+
// don't return zero
653+
if progress == 0 {
654+
progress = 1
655+
}
656+
task.Progress = progress
657657
resp.Code = backuppb.ResponseCode_Success
658658
resp.Msg = "success"
659659
resp.Data = task

0 commit comments

Comments
 (0)