working commit
This commit is contained in:
@@ -239,6 +239,13 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) {
|
|||||||
params := &operator.DeleteColletionParams{
|
params := &operator.DeleteColletionParams{
|
||||||
Path: cpath,
|
Path: cpath,
|
||||||
}
|
}
|
||||||
|
err := rctx.BindQuery(params)
|
||||||
|
if err != nil {
|
||||||
|
hand.logg.Errorf("DeleteColletion binding error: %v", err)
|
||||||
|
rctx.SetStatus(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Rigth checking
|
// Rigth checking
|
||||||
operatorID, _ := rctx.GetString(userTag)
|
operatorID, _ := rctx.GetString(userTag)
|
||||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ func (oper *Operator) ListCollections(ctx context.Context, operID string, param
|
|||||||
// DeleteColletion
|
// DeleteColletion
|
||||||
type DeleteColletionParams struct {
|
type DeleteColletionParams struct {
|
||||||
Path string
|
Path string
|
||||||
|
IsPattern bool `params:"isPattern"`
|
||||||
}
|
}
|
||||||
type DeleteColletionResult struct {
|
type DeleteColletionResult struct {
|
||||||
Files []descr.File `json:"collection,omitempty"`
|
Files []descr.File `json:"collection,omitempty"`
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ func (util *FileUtil) CreateCollectionCmds() *cobra.Command {
|
|||||||
Run: util.DeleteCollection,
|
Run: util.DeleteCollection,
|
||||||
}
|
}
|
||||||
deleteCollectionCmd.Flags().BoolVarP(&util.deleteCollectionParams.Detail, "detail", "D", false, "Show detail file information")
|
deleteCollectionCmd.Flags().BoolVarP(&util.deleteCollectionParams.Detail, "detail", "D", false, "Show detail file information")
|
||||||
|
deleteCollectionCmd.Flags().BoolVarP(&util.deleteCollectionParams.Recursive, "recursive", "R", false, "Use path as collection pattern")
|
||||||
|
|
||||||
subCmd.AddCommand(deleteCollectionCmd)
|
subCmd.AddCommand(deleteCollectionCmd)
|
||||||
|
|
||||||
return subCmd
|
return subCmd
|
||||||
@@ -428,6 +430,7 @@ func (util *FileUtil) listCollections(common *CommonFileParams, params *ListColl
|
|||||||
type DeleteCollectionParams struct {
|
type DeleteCollectionParams struct {
|
||||||
Path string
|
Path string
|
||||||
Detail bool
|
Detail bool
|
||||||
|
Recursive bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteCollectionResult struct {
|
type DeleteCollectionResult struct {
|
||||||
@@ -451,7 +454,7 @@ func (util *FileUtil) deleteCollection(common *CommonFileParams, params *DeleteC
|
|||||||
}
|
}
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||||
files, err := client.NewClient().DeleteCollection(ctx, params.Path)
|
files, err := client.NewClient().DeleteCollection(ctx, params.Path, params.Recursive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -19,6 +19,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"mstore/app/descr"
|
"mstore/app/descr"
|
||||||
"mstore/pkg/auxhttp"
|
"mstore/pkg/auxhttp"
|
||||||
@@ -323,7 +324,7 @@ func (cli *Client) ListCollections(ctx context.Context, catalogURI string) ([]st
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string) ([]descr.File, error) {
|
func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string, isPattern bool) ([]descr.File, error) {
|
||||||
var err error
|
var err error
|
||||||
res := make([]descr.File, 0)
|
res := make([]descr.File, 0)
|
||||||
|
|
||||||
@@ -335,6 +336,14 @@ func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string) ([]d
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
if isPattern {
|
||||||
|
values := url.Values{}
|
||||||
|
values.Add("isPattern","true")
|
||||||
|
catalogURI = catalogURI + "?" + values.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, catalogURI, nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, catalogURI, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
|
|||||||
Reference in New Issue
Block a user