mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
batch delete EC needles
fix https://github.com/seaweedfs/seaweedfs/issues/4107
This commit is contained in:
parent
8aec430df7
commit
7bdae5172e
|
@ -28,6 +28,7 @@ func (vs *VolumeServer) BatchDelete(ctx context.Context, req *volume_server_pb.B
|
|||
|
||||
n := new(needle.Needle)
|
||||
volumeId, _ := needle.NewVolumeId(vid)
|
||||
ecVolume, isEcVolume := vs.store.FindEcVolume(volumeId)
|
||||
if req.SkipCookieCheck {
|
||||
n.Id, _, err = needle.ParseNeedleIdCookie(id_cookie)
|
||||
if err != nil {
|
||||
|
@ -40,6 +41,7 @@ func (vs *VolumeServer) BatchDelete(ctx context.Context, req *volume_server_pb.B
|
|||
} else {
|
||||
n.ParsePath(id_cookie)
|
||||
cookie := n.Cookie
|
||||
if !isEcVolume {
|
||||
if _, err := vs.store.ReadVolumeNeedle(volumeId, n, nil, nil); err != nil {
|
||||
resp.Results = append(resp.Results, &volume_server_pb.DeleteResult{
|
||||
FileId: fid,
|
||||
|
@ -48,6 +50,16 @@ func (vs *VolumeServer) BatchDelete(ctx context.Context, req *volume_server_pb.B
|
|||
})
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if _, err := vs.store.ReadEcShardNeedle(volumeId, n, nil); err != nil {
|
||||
resp.Results = append(resp.Results, &volume_server_pb.DeleteResult{
|
||||
FileId: fid,
|
||||
Status: http.StatusNotFound,
|
||||
Error: err.Error(),
|
||||
})
|
||||
continue
|
||||
}
|
||||
}
|
||||
if n.Cookie != cookie {
|
||||
resp.Results = append(resp.Results, &volume_server_pb.DeleteResult{
|
||||
FileId: fid,
|
||||
|
@ -68,6 +80,7 @@ func (vs *VolumeServer) BatchDelete(ctx context.Context, req *volume_server_pb.B
|
|||
}
|
||||
|
||||
n.LastModified = now
|
||||
if !isEcVolume {
|
||||
if size, err := vs.store.DeleteVolumeNeedle(volumeId, n); err != nil {
|
||||
resp.Results = append(resp.Results, &volume_server_pb.DeleteResult{
|
||||
FileId: fid,
|
||||
|
@ -81,6 +94,21 @@ func (vs *VolumeServer) BatchDelete(ctx context.Context, req *volume_server_pb.B
|
|||
Size: uint32(size)},
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if size, err := vs.store.DeleteEcShardNeedle(ecVolume, n, n.Cookie); err != nil {
|
||||
resp.Results = append(resp.Results, &volume_server_pb.DeleteResult{
|
||||
FileId: fid,
|
||||
Status: http.StatusInternalServerError,
|
||||
Error: err.Error()},
|
||||
)
|
||||
} else {
|
||||
resp.Results = append(resp.Results, &volume_server_pb.DeleteResult{
|
||||
FileId: fid,
|
||||
Status: http.StatusAccepted,
|
||||
Size: uint32(size)},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
|
Loading…
Reference in a new issue