Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine Delete API #376

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions core/backup_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ func (b *BackupContext) DeleteBackup(ctx context.Context, request *backuppb.Dele
getResp := b.GetBackup(b.ctx, &backuppb.GetBackupRequest{
BackupName: request.GetBackupName(),
})
// always trigger a remove to make sure it is deleted
err := b.getStorageClient().RemoveWithPrefix(ctx, b.backupBucketName, BackupDirPath(b.backupRootPath, request.GetBackupName()))

if getResp.GetCode() == backuppb.ResponseCode_Request_Object_Not_Found {
resp.Code = backuppb.ResponseCode_Request_Object_Not_Found
resp.Msg = getResp.GetMsg()
Expand All @@ -409,11 +412,11 @@ func (b *BackupContext) DeleteBackup(ctx context.Context, request *backuppb.Dele
return resp
}

err := b.getStorageClient().RemoveWithPrefix(ctx, b.backupBucketName, BackupDirPath(b.backupRootPath, request.GetBackupName()))

if err != nil {
log.Error("Fail to delete backup", zap.String("backupName", request.GetBackupName()), zap.Error(err))
return nil
resp.Code = backuppb.ResponseCode_Fail
resp.Msg = getResp.GetMsg()
return resp
}

resp.Code = backuppb.ResponseCode_Success
Expand Down
Loading