Skip to content

Commit

Permalink
Refine Delete API (#376)
Browse files Browse the repository at this point in the history
Signed-off-by: wayblink <[email protected]>
  • Loading branch information
wayblink authored Jul 5, 2024
1 parent 197ad69 commit 80cd2b9
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit 80cd2b9

Please sign in to comment.