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