mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
fix: crash in storage rest client due to spurious query params (#9924)
regression got introduced in dee3cf2d7f
when the DeleteVersion API was changed, but the corresponding query
params were left in-tact.
This commit is contained in:
parent
cf5d051afc
commit
f7f12b8604
@ -289,8 +289,9 @@ func (client *storageRESTClient) DeleteVersion(volume, path string, fi FileInfo)
|
||||
values.Set(storageRESTFilePath, path)
|
||||
|
||||
var buffer bytes.Buffer
|
||||
encoder := gob.NewEncoder(&buffer)
|
||||
encoder.Encode(&fi)
|
||||
if err := gob.NewEncoder(&buffer).Encode(fi); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
respBody, err := client.call(storageRESTMethodDeleteVersion, values, &buffer, -1)
|
||||
defer http.DrainBody(respBody)
|
||||
|
@ -61,7 +61,6 @@ const (
|
||||
storageRESTFilePath = "file-path"
|
||||
storageRESTVersionID = "version-id"
|
||||
storageRESTTotalVersions = "total-versions"
|
||||
storageRESTDeleteMarker = "delete-marker"
|
||||
storageRESTSrcVolume = "source-volume"
|
||||
storageRESTSrcPath = "source-path"
|
||||
storageRESTDataDir = "data-dir"
|
||||
|
@ -287,9 +287,13 @@ func (s *storageRESTServer) DeleteVersionHandler(w http.ResponseWriter, r *http.
|
||||
volume := vars[storageRESTVolume]
|
||||
filePath := vars[storageRESTFilePath]
|
||||
|
||||
if r.ContentLength < 0 {
|
||||
s.writeErrorResponse(w, errInvalidArgument)
|
||||
return
|
||||
}
|
||||
|
||||
var fi FileInfo
|
||||
decoder := gob.NewDecoder(r.Body)
|
||||
if err := decoder.Decode(&fi); err != nil {
|
||||
if err := gob.NewDecoder(r.Body).Decode(&fi); err != nil {
|
||||
s.writeErrorResponse(w, err)
|
||||
return
|
||||
}
|
||||
@ -300,7 +304,7 @@ func (s *storageRESTServer) DeleteVersionHandler(w http.ResponseWriter, r *http.
|
||||
}
|
||||
}
|
||||
|
||||
// ReadVersion delete updated metadata.
|
||||
// ReadVersion read metadata of versionID
|
||||
func (s *storageRESTServer) ReadVersionHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if !s.IsValid(w, r) {
|
||||
return
|
||||
@ -858,7 +862,7 @@ func registerStorageRESTHandlers(router *mux.Router, endpointZones EndpointZones
|
||||
subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodWriteMetadata).HandlerFunc(httpTraceHdrs(server.WriteMetadataHandler)).
|
||||
Queries(restQueries(storageRESTVolume, storageRESTFilePath)...)
|
||||
subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodDeleteVersion).HandlerFunc(httpTraceHdrs(server.DeleteVersionHandler)).
|
||||
Queries(restQueries(storageRESTVolume, storageRESTFilePath, storageRESTVersionID, storageRESTDeleteMarker)...)
|
||||
Queries(restQueries(storageRESTVolume, storageRESTFilePath)...)
|
||||
subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodReadVersion).HandlerFunc(httpTraceHdrs(server.ReadVersionHandler)).
|
||||
Queries(restQueries(storageRESTVolume, storageRESTFilePath, storageRESTVersionID)...)
|
||||
subrouter.Methods(http.MethodPost).Path(storageRESTVersionPrefix + storageRESTMethodRenameData).HandlerFunc(httpTraceHdrs(server.RenameDataHandler)).
|
||||
|
Loading…
Reference in New Issue
Block a user