browser: Send correct arguments for RemoveObjects web handler. (#3848)

Fixes #3839
master
Krishna Srinivas 8 years ago committed by Harshavardhana
parent 05e53f1b34
commit 0bae3330e8
  1. 9
      browser/app/js/components/Browse.js
  2. 1
      browser/app/js/reducers.js
  3. 8
      cmd/web-handlers.go
  4. 4
      cmd/web-handlers_test.go

@ -228,12 +228,13 @@ export default class Browse extends React.Component {
removeObject() { removeObject() {
const {web, dispatch, currentPath, currentBucket, deleteConfirmation} = this.props const {web, dispatch, currentPath, currentBucket, deleteConfirmation} = this.props
web.RemoveObject({ web.RemoveObject({
bucketName: currentBucket, bucketname: currentBucket,
objectName: deleteConfirmation.object objects: [deleteConfirmation.object]
}) })
.then(() => { .then(() => {
this.hideDeleteConfirmation() this.hideDeleteConfirmation()
dispatch(actions.removeObject(deleteConfirmation.object)) let delObject = deleteConfirmation.object.replace(currentPath, '')
dispatch(actions.removeObject(delObject))
}) })
.catch(e => dispatch(actions.showAlert({ .catch(e => dispatch(actions.showAlert({
type: 'danger', type: 'danger',
@ -759,4 +760,4 @@ export default class Browse extends React.Component {
</div> </div>
) )
} }
} }

@ -199,7 +199,6 @@ export default (state = {
newState.checkedObjects = [] newState.checkedObjects = []
break break
} }
console.log(newState.checkedObjects)
return newState return newState
} }

@ -257,7 +257,7 @@ func (web *webAPIHandlers) ListObjects(r *http.Request, args *ListObjectsArgs, r
// RemoveObjectArgs - args to remove an object // RemoveObjectArgs - args to remove an object
// JSON will look like: // JSON will look like:
// '{"bucketname":"testbucket","prefix":"john/pics/","objects":["hawaii/","maldives/","sanjose.jpg"]}' // '{"bucketname":"testbucket","objects":["photos/hawaii/","photos/maldives/","photos/sanjose.jpg"]}'
type RemoveObjectArgs struct { type RemoveObjectArgs struct {
Objects []string `json:"objects"` // can be files or sub-directories Objects []string `json:"objects"` // can be files or sub-directories
Prefix string `json:"prefix"` // current directory in the browser-ui Prefix string `json:"prefix"` // current directory in the browser-ui
@ -300,8 +300,8 @@ objectLoop:
return err return err
} }
if !hasSuffix(object, slashSeparator) { if !hasSuffix(object, slashSeparator) {
// If not a directory, compress the file and write it to response. // If not a directory, remove the object.
err = remove(pathJoin(args.Prefix, object)) err = remove(object)
if err != nil { if err != nil {
break objectLoop break objectLoop
} }
@ -311,7 +311,7 @@ objectLoop:
marker := "" marker := ""
for { for {
var lo ListObjectsInfo var lo ListObjectsInfo
lo, err = objectAPI.ListObjects(args.BucketName, pathJoin(args.Prefix, object), marker, "", 1000) lo, err = objectAPI.ListObjects(args.BucketName, object, marker, "", 1000)
if err != nil { if err != nil {
break objectLoop break objectLoop
} }

@ -477,7 +477,7 @@ func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrH
t.Fatalf("Was not able to upload an object, %v", err) t.Fatalf("Was not able to upload an object, %v", err)
} }
removeObjectRequest := RemoveObjectArgs{BucketName: bucketName, Prefix: "", Objects: []string{"a/", "object"}} removeObjectRequest := RemoveObjectArgs{BucketName: bucketName, Objects: []string{"a/", "object"}}
removeObjectReply := &WebGenericRep{} removeObjectReply := &WebGenericRep{}
req, err := newTestWebRPCRequest("Web.RemoveObject", authorization, removeObjectRequest) req, err := newTestWebRPCRequest("Web.RemoveObject", authorization, removeObjectRequest)
if err != nil { if err != nil {
@ -492,7 +492,7 @@ func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrH
t.Fatalf("Failed, %v", err) t.Fatalf("Failed, %v", err)
} }
removeObjectRequest = RemoveObjectArgs{BucketName: bucketName, Prefix: "", Objects: []string{"a/", "object"}} removeObjectRequest = RemoveObjectArgs{BucketName: bucketName, Objects: []string{"a/", "object"}}
removeObjectReply = &WebGenericRep{} removeObjectReply = &WebGenericRep{}
req, err = newTestWebRPCRequest("Web.RemoveObject", authorization, removeObjectRequest) req, err = newTestWebRPCRequest("Web.RemoveObject", authorization, removeObjectRequest)
if err != nil { if err != nil {

Loading…
Cancel
Save